public IActionResult Patch([FromODataUri] int productTypeId, [FromBody] Delta <ProductTypeDto> productTypeDelta) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_productTypeRepository.ProductTypeExists(productTypeId)) { return(NotFound()); } var productTypeToPatch = Mapper.Map <Delta <ProductType> >(productTypeDelta); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!TryValidateModel(productTypeToPatch)) { return(BadRequest()); } var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var profile = _accountRepository.GetUserProfile(userId); if (!_productTypeRepository.PartialUpdateProductType(productTypeId, productTypeToPatch, profile.UserProfileId)) { return(StatusCode(500, "A problem happened while handling your request.")); } return(NoContent()); } catch (Exception ex) { _logger.LogError($"Failed in Patch /ProductTypes(productTypeId): {ex}"); return(StatusCode(500, "A problem happened while handling your request.")); } }