public async Task <IActionResult> Edit([FromQuery] Guid id, [FromBody] LabelPutDto labelPutDto) { if (id != labelPutDto.ID) { return(BadRequest()); } await labelService.UpdateAsync(labelPutDto); return(NoContent()); }
public async Task <bool> UpdateAsync(LabelPutDto proPlanPutDto) { LabelPutDtoValidator validator = new LabelPutDtoValidator(); ValidationResult results = validator.Validate(proPlanPutDto); if (!results.IsValid) { throw new ValidationException("proPlanPutDTO", string.Join(". ", results.Errors)); } Label project = await _repository.GetByIdAsync(proPlanPutDto.ID); if (project == null) { throw new NotFoundException($"The server can not find the requested Label with ID: {proPlanPutDto.ID}"); } return(await _repository.UpdateAsync(mapper.Map <Label>(proPlanPutDto)) != null); }