public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteInventoryPostingRuleDto value) { var idObj = id; if (value.InventoryPostingRuleId == null) { value.InventoryPostingRuleId = idObj; } else if (!((ICreateOrMergePatchOrDeleteInventoryPostingRule)value).InventoryPostingRuleId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.InventoryPostingRuleId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteInventoryPostingRuleDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; InventoryPostingRulesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryPostingRuleApplicationService.When(value as IMergePatchInventoryPostingRule); return; } // /////////////////////////////// InventoryPostingRulesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _inventoryPostingRuleApplicationService.When(value as ICreateInventoryPostingRule); } catch (Exception ex) { var response = InventoryPostingRulesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }