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); } }
public ActionResult AddUserTask(CreateUserTaskRequest createRequest) { var newUserTask = _repository.AddUserTask(createRequest.UserId, createRequest.TaskId); return(Created($"api/userTask/{newUserTask.Id}", newUserTask)); }