示例#1
0
        public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteOrderShipmentDto value)
        {
            var idObj = ParseIdString(id.IsNormalized() ? id : id.Normalize());

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

                OrderShipmentsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderShipmentApplicationService.When(value as ICreateOrderShipment);
            } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }