public IActionResult Patch([FromODataUri] int addressTypeId, [FromBody] Delta <AddressTypeDto> addressTypeDelta) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_addressTypeRepository.AddressTypeExists(addressTypeId)) { return(NotFound()); } var addressTypeToPatch = Mapper.Map <Delta <AddressType> >(addressTypeDelta); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!TryValidateModel(addressTypeToPatch)) { return(BadRequest()); } var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var profile = _accountRepository.GetUserProfile(userId); if (!_addressTypeRepository.PartialUpdateAddressType(addressTypeId, addressTypeToPatch, profile.UserProfileId)) { return(StatusCode(500, "A problem happened while handling your request.")); } return(NoContent()); } catch (Exception ex) { _logger.LogError($"Failed in Patch /AddressTypes(addressTypeId): {ex}"); return(StatusCode(500, "A problem happened while handling your request.")); } }