예제 #1
0
        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)));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }