示例#1
0
        public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteShipmentDto value)
        {
            var idObj = id;

            if (value.ShipmentId == null)
            {
                value.ShipmentId = idObj;
            }
            else if (!((ICreateOrMergePatchOrDeleteShipment)value).ShipmentId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.ShipmentId);
            }
        }
示例#2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteShipmentDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    ShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _shipmentApplicationService.When(value as IMergePatchShipment);
                    return;
                }
                // ///////////////////////////////

                ShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _shipmentApplicationService.When(value as ICreateShipment);
            } catch (Exception ex) { var response = ShipmentsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }