public IHttpActionResult UpdateScrumTask(int id, ScrumTaskUpdateDto taskDto) { var task = _scrumTasksService.Update(id, taskDto); if (task == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest()); } return(Ok(new { took = task.Took?.Value })); }
public ScrumTask Update(int taskId, ScrumTaskUpdateDto taskDto) { var taskFromDb = _unitOfWork.ScrumTasks.Get(taskId); if (taskFromDb == null) { return(null); } if (!string.IsNullOrWhiteSpace(taskDto.Title)) { UpdateTitle(taskFromDb, taskDto.Title); } if (!string.IsNullOrWhiteSpace(taskDto.Content)) { UpdateContent(taskFromDb, taskDto.Content); } if (!string.IsNullOrWhiteSpace(taskDto.UserId)) { UpdateUser(taskFromDb, taskDto.UserId); } if (taskDto.EstimationId != null) { UpdateEstimation(taskFromDb, taskDto.EstimationId.Value); } if (taskDto.Priority != null) { UpdatePriority(taskFromDb, taskDto.Priority.Value); } if (taskDto.TaskType != null) { UpdateTaskType(taskFromDb, taskDto.TaskType.Value, taskDto.TookId); } Validate(taskFromDb); if (_validationDictionary.IsValid) { _unitOfWork.Complate(); } return(taskFromDb); }