/// <inheritdoc /> public async Task <bool> UpdateAsync(TaskPutDto taskDto) { var task = _mapper.Map <Task>(taskDto); _taskRepository.Update(task); var affectedRows = await _taskRepository.SaveChangesAsync(); return(affectedRows > 0); }
public async Task <IActionResult> Edit([FromRoute] Guid id, [FromBody] TaskPutDto taskPutDto) { if (id != taskPutDto.ID) { return(BadRequest()); } await taskService.UpdateAsync(taskPutDto); return(NoContent()); }
public async Task <bool> UpdateAsync(TaskPutDto taskPutDto) { TaskPutDtoValidator validator = new TaskPutDtoValidator(); ValidationResult results = validator.Validate(taskPutDto); if (!results.IsValid) { throw new ValidationException("taskPutDTO", string.Join(". ", results.Errors)); } Models.Task project = await _repository.GetByIdAsync(taskPutDto.ID); if (project == null) { throw new NotFoundException($"The server can not find the requested Task with ID: {taskPutDto.ID}"); } return(await _repository.UpdateAsync(mapper.Map <Models.Task>(taskPutDto)) != null); }
public async Task <IActionResult> PutAsync([FromRoute] int id, [FromBody] TaskPutDto taskDto) { if (id != taskDto.Id) { return(BadRequest()); } if (taskDto == null) { return(BadRequest()); } var isTaskUpdated = await _taskService.UpdateAsync(taskDto); if (!isTaskUpdated) { return(BadRequest()); } return(NoContent()); }