public async Task <ServiceResult> GetTaskViewModel([FromBody] int statusId) { var userId = int.Parse(_caller.Claims.FirstOrDefault(x => x.Type == "id").Value); var taskPriorities = await _taskPriorityService.GetAllAsync(); var taskStatuses = await _taskStatusService.GetAllAsync(); var tasks = await _taskService.GetTasks(userId); foreach (var item in taskStatuses) { item.TaskCount = tasks.Count(x => x.TaskStatusId == item.Id); } ServiceResult = new ServiceResult { MessageType = Todo.Core.Enums.EMessageType.Success, Result = new TaskViewModel { TaskPriorities = taskPriorities.ToList(), TaskStatuses = taskStatuses.ToList(), Tasks = tasks.Where(x => x.TaskStatusId == statusId || statusId == 0).ToList() } }; return(ServiceResult); }
public async Task <IEnumerable <TaskStatusModel> > GetTaskStatusModels() { return(await _repository.GetAllAsync()); }