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