Beispiel #1
0
        public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteOrderDto value)
        {
            var idObj = id;

            if (value.OrderId == null)
            {
                value.OrderId = idObj;
            }
            else if (!((ICreateOrMergePatchOrDeleteOrder)value).OrderId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.OrderId);
            }
        }
Beispiel #2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteOrderDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    OrdersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _orderApplicationService.When(value as IMergePatchOrder);
                    return;
                }
                // ///////////////////////////////

                OrdersControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _orderApplicationService.When(value as ICreateOrder);
            } catch (Exception ex) { var response = OrdersControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }