public ActionResult CreateTask([FromBody] AddProjectTaskDto task) { if (task == null) { return(BadRequest()); } var addedTask = _taskService.Add(task); return(CreatedAtAction("CreateTask", new { id = addedTask.Id }, addedTask)); }
public ProjectTaskDto Add(AddProjectTaskDto taskDto) { var task = _mapper.Map <ProjectTask>(taskDto); task.State = TaskState.Planned; _taskRepository.Add(task); if (!_taskRepository.Save()) { throw new PmsException("Create a task failed on save"); } UpdateProjectState(task.ProjectId); return(_mapper.Map <ProjectTaskDto>(task)); }