Пример #1
0
        public async Task <List <UserTaskResponse> > CreateUserTaskAsync(CreateUserTaskRequest userTask)
        {
            var taskToAdd = _mapper.Map <UserTask>(userTask);

            taskToAdd.Project = await _userProjectRepository.GetUserProjectByIdAsync(userTask.ProjectId);

            var operationResult = await _userTaskRepository.AddUserTaskAsync(taskToAdd);

            if (operationResult != null)
            {
                return(_mapper.Map <List <UserTaskResponse> >(await GetProjectTasksAsync(userTask.ProjectId)));
            }
            else
            {
                _logger.LogWarning("CreateUserTaskAsync: Task was not added.", userTask);
                return(null);
            }
        }
Пример #2
0
        public ActionResult AddUserTask(CreateUserTaskRequest createRequest)
        {
            var newUserTask = _repository.AddUserTask(createRequest.UserId, createRequest.TaskId);

            return(Created($"api/userTask/{newUserTask.Id}", newUserTask));
        }