public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteInventoryItemRequirementDto value) { var idObj = ParseIdString(id.IsNormalized() ? id : id.Normalize()); if (value.InventoryItemRequirementId == null) { value.InventoryItemRequirementId = idObj; } else if (!((ICreateOrMergePatchOrDeleteInventoryItemRequirement)value).InventoryItemRequirementId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.InventoryItemRequirementId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteInventoryItemRequirementDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; InventoryItemRequirementsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryItemRequirementApplicationService.When(value as IMergePatchInventoryItemRequirement); return; } // /////////////////////////////// InventoryItemRequirementsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryItemRequirementApplicationService.When(value as ICreateInventoryItemRequirement); } catch (Exception ex) { var response = InventoryItemRequirementsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }