public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteProductCategoryDto value) { var idObj = id; if (value.ProductCategoryId == null) { value.ProductCategoryId = idObj; } else if (!((ICreateOrMergePatchOrDeleteProductCategory)value).ProductCategoryId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.ProductCategoryId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteProductCategoryDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; ProductCategoriesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _productCategoryApplicationService.When(value as IMergePatchProductCategory); return; } // /////////////////////////////// ProductCategoriesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _productCategoryApplicationService.When(value as ICreateProductCategory); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }