public async Task <IActionResult> UpdateContact([FromRoute] Guid id, [FromBody] ContactUpdateVM contactUpdateVM) { if (id != contactUpdateVM.Id) { return(BadRequest()); } return(Ok(await _mediator.Send(new UpdateContact() { ContactUpdateVM = contactUpdateVM }))); }
public async Task <Response> Handle(PatchContact request, CancellationToken cancellationToken) { IRepository <Contact> repository = _unitOfWork.GetRepository <Contact>(); Contact contact = await repository.GetByIdAsync(request.Id); ContactUpdateVM contactUpdateVM = _mapper.Map <ContactUpdateVM>(contact); request.PatchDocument.ApplyTo(contactUpdateVM); return(await _mediator.Send(new UpdateContact() { ContactUpdateVM = contactUpdateVM }, cancellationToken)); }