public static string ToIdString(OrderItemShipGrpInvResId id)
        {
            var formatter = (new ValueObjectTextFormatter <OrderItemShipGrpInvResId>());
            var idStr     = formatter.ToString(id);

            return(idStr);
        }
        public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version)
        {
            Type supportedEventType = typeof(OrderItemShipGrpInvReservationEventBase);

            if (!eventType.IsAssignableFrom(supportedEventType))
            {
                throw new NotSupportedException();
            }
            OrderItemShipGrpInvResId idObj = (OrderItemShipGrpInvResId)(eventStoreAggregateId as EventStoreAggregateId).Id;
            var criteria = CurrentSession.CreateCriteria <OrderItemShipGrpInvReservationEventBase>();

            criteria.Add(Restrictions.Eq("OrderItemShipGrpInvReservationEventId.OrderItemShipGrpInvResIdOrderId", idObj.OrderId));
            criteria.Add(Restrictions.Eq("OrderItemShipGrpInvReservationEventId.OrderItemShipGrpInvResIdShipGroupSeqId", idObj.ShipGroupSeqId));
            criteria.Add(Restrictions.Eq("OrderItemShipGrpInvReservationEventId.OrderItemShipGrpInvResIdOrderItemSeqId", idObj.OrderItemSeqId));
            criteria.Add(Restrictions.Eq("OrderItemShipGrpInvReservationEventId.OrderItemShipGrpInvResIdProductId", idObj.ProductId));
            criteria.Add(Restrictions.Eq("OrderItemShipGrpInvReservationEventId.OrderItemShipGrpInvResIdLocatorId", idObj.LocatorId));
            criteria.Add(Restrictions.Eq("OrderItemShipGrpInvReservationEventId.OrderItemShipGrpInvResIdAttributeSetInstanceId", idObj.AttributeSetInstanceId));
            criteria.Add(Restrictions.Le("OrderItemShipGrpInvReservationEventId.Version", version));
            criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("OrderItemShipGrpInvReservationEventId.Version"));
            var es = criteria.List <IEvent>();

            foreach (OrderItemShipGrpInvReservationEventBase e in es)
            {
                e.EventReadOnly = true;
            }
            return(new EventStream()
            {
                SteamVersion = es.Count > 0 ? ((OrderItemShipGrpInvReservationEventBase)es.Last()).OrderItemShipGrpInvReservationEventId.Version : default(long),
                Events = es
            });
        }
        public IOrderItemShipGrpInvReservationState Get(OrderItemShipGrpInvResId id)
        {
            IOrderItemShipGrpInvReservationState state = CurrentSession.Get <OrderItemShipGrpInvReservationState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IOrderItemShipGrpInvReservationState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IOrderItemShipGrpInvReservationEvent> GetStateEventAsync(OrderItemShipGrpInvResId orderItemShipGrpInvResId, long version)
        {
            var idObj         = OrderItemShipGrpInvReservationProxyUtils.ToIdString(orderItemShipGrpInvResId);
            var uriParameters = new OrderItemShipGrpInvReservationStateEventUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new OrderItemShipGrpInvReservationStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.OrderItemShipGrpInvReservationStateEvent.Get(req);

            OrderItemShipGrpInvReservationProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public IOrderItemShipGrpInvReservationState Get(OrderItemShipGrpInvResId id, bool nullAllowed)
        {
            IOrderItemShipGrpInvReservationState state = CurrentSession.Get <OrderItemShipGrpInvReservationState> (id);

            if (!nullAllowed && state == null)
            {
                state = new OrderItemShipGrpInvReservationState();
                (state as OrderItemShipGrpInvReservationState).OrderItemShipGrpInvResId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IOrderItemShipGrpInvReservationState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IOrderItemShipGrpInvReservationState> GetAsync(OrderItemShipGrpInvResId orderItemShipGrpInvResId)
        {
            IOrderItemShipGrpInvReservationState state = null;
            var idObj         = OrderItemShipGrpInvReservationProxyUtils.ToIdString(orderItemShipGrpInvResId);
            var uriParameters = new OrderItemShipGrpInvReservationUriParameters();

            uriParameters.Id = idObj;

            var req = new OrderItemShipGrpInvReservationGetRequest(uriParameters);

            var resp = await _ramlClient.OrderItemShipGrpInvReservation.Get(req);

            OrderItemShipGrpInvReservationProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToOrderItemShipGrpInvReservationState();
            return(state);
        }
 public virtual IOrderItemShipGrpInvReservationState GetHistoryState(OrderItemShipGrpInvResId orderItemShipGrpInvResId, long version)
 {
     return(GetHistoryStateAsync(orderItemShipGrpInvResId, version).GetAwaiter().GetResult());
 }
        public async Task <IOrderItemShipGrpInvReservationState> GetHistoryStateAsync(OrderItemShipGrpInvResId orderItemShipGrpInvResId, long version)
        {
            var idObj         = OrderItemShipGrpInvReservationProxyUtils.ToIdString(orderItemShipGrpInvResId);
            var uriParameters = new OrderItemShipGrpInvReservationHistoryStateUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new OrderItemShipGrpInvReservationHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.OrderItemShipGrpInvReservationHistoryState.Get(req);

            OrderItemShipGrpInvReservationProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToOrderItemShipGrpInvReservationState());
        }
 public IOrderItemShipGrpInvReservationEvent GetEvent(OrderItemShipGrpInvResId orderItemShipGrpInvResId, long version)
 {
     return(GetStateEventAsync(orderItemShipGrpInvResId, version).GetAwaiter().GetResult());
 }
 public IOrderItemShipGrpInvReservationState Get(OrderItemShipGrpInvResId orderItemShipGrpInvResId)
 {
     return(GetAsync(orderItemShipGrpInvResId).GetAwaiter().GetResult());
 }
Ejemplo n.º 11
0
 public override IEventStoreAggregateId ToEventStoreAggregateId(OrderItemShipGrpInvResId aggregateId)
 {
     return(new EventStoreAggregateId(aggregateId));
 }