private Friend UpdateMapper(Friend friend, FriendPutDto dto) { friend.Name = dto.Name; friend.Nickname = dto.Nickname; friend.Whatsapp = dto.Whatsapp; return(friend); }
public async Task <IActionResult> Update(FriendPutDto dto) { var validationResult = await _app.Update(dto); if (!validationResult.IsValid) { return(BadRequest(validationResult.Errors.Select(x => x.ErrorMessage).ToList())); } return(NoContent()); }
public async Task <ValidationResult> Update(FriendPutDto dto) { var friend = await _uow.FriendRepository.GetByIdAsync(dto.Id); friend = UpdateMapper(friend, dto); var validationResult = await _friendValidation.UpdateValidation.ValidateAsync(friend); if (!validationResult.IsValid) { return(validationResult); } _uow.FriendRepository.Edit(friend); await _uow.CommitAsync(); return(validationResult); }