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