public async Task <IActionResult> GetAll([FromRoute] SmartLists smartListName, [FromQuery] SortOrderViewModel sortOrderViewModel, [FromQuery] bool uncompletedOnly = false) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var list = await _toDoListService.GetSmartList(smartListName, uncompletedOnly); list.Sort(sortOrderViewModel); return(Ok(list)); }
public Task <List> GetSmartList(SmartLists smartListName, bool uncompletedOnly = false) { return(smartListName switch { SmartLists.AllTasks => CreateVirtualList("All tasks", todo => true, uncompletedOnly), SmartLists.DueDateSet => CreateVirtualList("Due Date Set", todo => todo.Deadline.HasValue, uncompletedOnly), SmartLists.ImportantTasks => CreateVirtualList("Important Tasks", todo => todo.Importance == ImportanceEnum.High, uncompletedOnly), SmartLists.TasksOfToday => CreateVirtualList("Today’s tasks", todo => todo.Deadline == DateTime.UtcNow, uncompletedOnly), _ => throw new NotImplementedException() });