public IActionResult GetTask(int taskId) { var tasks = _repo.GetTasks(); if (tasks == null || !tasks.Any()) { return(NotFound()); } var task = tasks.FirstOrDefault(o => o.Id == taskId); return(Ok(ModelsMapping.GetTaskDto(task))); }
public IActionResult GetTasksForUser(int userId) { if (_repo.GetUser(userId) == null) { return(NotFound()); } var userTasks = _repo.GetTasksForUser(userId).Select(o => ModelsMapping.GetTaskDto(o)); if (userTasks == null || !userTasks.Any()) { return(NotFound()); } return(Ok(userTasks)); }
public IActionResult GetIUnclosedTaskForUser(int userId) { if (_repo.GetUser(userId) == null) { return(NotFound()); } var userTasks = _repo.GetTasksForUser(userId).Select(o => ModelsMapping.GetTaskDto(o)); if (userTasks == null || !userTasks.Any()) { return(NotFound()); } var userWorkTimes = _repo.GetWorkTimesForUser(userId); if (userWorkTimes == null || !userWorkTimes.Any()) { return(NotFound()); } var unfinishedWorkTime = userWorkTimes.FirstOrDefault(o => !EntitiesUtils.IsDateEmpty(o.WorkStartTime) && EntitiesUtils.IsDateEmpty(o.WorkEndTime)); if (unfinishedWorkTime == null) { return(NotFound()); } var unfinishedTask = userTasks.FirstOrDefault(o => o.Id == unfinishedWorkTime.TaskId); if (unfinishedTask == null) { return(NotFound()); } return(Ok(unfinishedTask)); }