public async Task <ActionResult> Update([FromRoute] int id, [FromBody] UpdateSellerContactDTO sellerContactDTO) { SellerContact sellerContact = await _sellerContactRepository.FindByIdAsync(id); if (sellerContact.IsNull()) { return(NotFound()); } _mapper.Map(sellerContactDTO, sellerContact); await _sellerContactRepository.UpdateAsync(sellerContact); return(NoContent()); }
public async Task <ActionResult> UpdatePartial([FromRoute] int id, [FromBody] JsonPatchDocument <UpdateSellerContactDTO> pacthSellerContactDTO) { SellerContact sellerContact = await _sellerContactRepository.FindByIdAsync(id); if (sellerContact.IsNull()) { return(NotFound()); } UpdateSellerContactDTO sellerDTO = _mapper.Map <UpdateSellerContactDTO>(sellerContact); pacthSellerContactDTO.ApplyTo(sellerDTO); if (!TryValidateModel(sellerDTO)) { return(ValidationProblem(ModelState)); } _mapper.Map(sellerDTO, sellerContact); await _sellerContactRepository.UpdateAsync(sellerContact); return(NoContent()); }