public async Task <ActionResult <ClientContact> > GetById([FromRoute] int id) { ClientContact clientContact = await _clientContactRepository.FindByIdAsync(id); if (clientContact.IsNull()) { return(NotFound()); } return(Ok(clientContact)); }
public async Task <ActionResult> Update([FromRoute] int id, [FromBody] UpdateClientContactDTO clientContactDTO) { ClientContact clientContact = await _clientContactRepository.FindByIdAsync(id); if (clientContact.IsNull()) { return(NotFound()); } _mapper.Map(clientContactDTO, clientContact); await _clientContactRepository.UpdateAsync(clientContact); return(NoContent()); }
public async Task <ActionResult> UpdatePartial([FromRoute] int id, [FromBody] JsonPatchDocument <UpdateClientContactDTO> pacthClientContactDTO) { ClientContact clientContact = await _clientContactRepository.FindByIdAsync(id); if (clientContact.IsNull()) { return(NotFound()); } UpdateClientContactDTO clientDTO = _mapper.Map <UpdateClientContactDTO>(clientContact); pacthClientContactDTO.ApplyTo(clientDTO); if (!TryValidateModel(clientDTO)) { return(ValidationProblem(ModelState)); } _mapper.Map(clientDTO, clientContact); await _clientContactRepository.UpdateAsync(clientContact); return(NoContent()); }