public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteSellableInventoryItemEntryMvoDto value) { var idObj = ParseIdString(id.IsNormalized() ? id : id.Normalize()); if (value.SellableInventoryItemEntryId == null) { value.SellableInventoryItemEntryId = idObj; } else if (!((ICreateOrMergePatchOrDeleteSellableInventoryItemEntryMvo)value).SellableInventoryItemEntryId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.SellableInventoryItemEntryId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteSellableInventoryItemEntryMvoDto value) { try { // /////////////////////////////// if (value.SellableInventoryItemVersion != default(long)) { value.CommandType = CommandType.MergePatch; SellableInventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _sellableInventoryItemEntryMvoApplicationService.When(value as IMergePatchSellableInventoryItemEntryMvo); return; } // /////////////////////////////// SellableInventoryItemEntryMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _sellableInventoryItemEntryMvoApplicationService.When(value as ICreateSellableInventoryItemEntryMvo); } catch (Exception ex) { var response = SellableInventoryItemEntryMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }