コード例 #1
0
        public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteShipmentTypeDto value)
        {
            var idObj = id;

            if (value.ShipmentTypeId == null)
            {
                value.ShipmentTypeId = idObj;
            }
            else if (!((ICreateOrMergePatchOrDeleteShipmentType)value).ShipmentTypeId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.ShipmentTypeId);
            }
        }
コード例 #2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentTypeDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    ShipmentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _shipmentTypeApplicationService.When(value as IMergePatchShipmentType);
                    return;
                }
                // ///////////////////////////////

                ShipmentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _shipmentTypeApplicationService.When(value as ICreateShipmentType);
            } catch (Exception ex) { var response = ShipmentTypesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }