public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteInventoryItemEntryMvoDto value) { var idObj = ParseIdString(id.IsNormalized() ? id : id.Normalize()); if (value.InventoryItemEntryId == null) { value.InventoryItemEntryId = idObj; } else if (!((ICreateOrMergePatchOrDeleteInventoryItemEntryMvo)value).InventoryItemEntryId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.InventoryItemEntryId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteInventoryItemEntryMvoDto value) { try { // /////////////////////////////// if (value.InventoryItemVersion != default(long)) { value.CommandType = CommandType.MergePatch; InventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryItemEntryMvoApplicationService.When(value as IMergePatchInventoryItemEntryMvo); return; } // /////////////////////////////// InventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryItemEntryMvoApplicationService.When(value as ICreateInventoryItemEntryMvo); } catch (Exception ex) { var response = InventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }