示例#1
0
        public async Task <ActionResult <ClientContact> > GetById([FromRoute] int id)
        {
            ClientContact clientContact = await _clientContactRepository.FindByIdAsync(id);

            if (clientContact.IsNull())
            {
                return(NotFound());
            }

            return(Ok(clientContact));
        }
示例#2
0
        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());
        }
示例#3
0
        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());
        }