Order todo list by creation time

pull/4/head
Dmitry Ignatiev 12 months ago
parent e30df62c21
commit 4be6ec03ef

@ -50,6 +50,8 @@ namespace TodoApi.Controllers
q = q.Take(Math.Min(t, MaxResultCount)); q = q.Take(Math.Min(t, MaxResultCount));
} }
q = q.OrderBy(e => e.CreatedAt);
var result = new var result = new
{ {
Items = await q.ToArrayAsync(), Items = await q.ToArrayAsync(),
@ -72,12 +74,12 @@ namespace TodoApi.Controllers
await _db.SaveChangesAsync(); await _db.SaveChangesAsync();
return Ok(todo); return Ok(todo);
} }
[HttpPost("toggle")] [HttpPost("toggle")]
public async Task<IActionResult> Toggle(ToggleModel vm) public async Task<IActionResult> Toggle(ToggleModel vm)
{ {
var now = DateTimeOffset.UtcNow; var now = DateTimeOffset.UtcNow;
await _db.Todos.Where(e => vm.Ids.Contains(e.Id)) await _db.Todos.Where(e => vm.Ids.Contains(e.Id))
.ExecuteUpdateAsync(setters => .ExecuteUpdateAsync(setters =>
setters setters

Loading…
Cancel
Save