public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version)
        {
            Type supportedEventType = typeof(GoodIdentificationMvoEventBase);

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

            criteria.Add(Restrictions.Eq("GoodIdentificationMvoEventId.ProductGoodIdentificationIdProductId", idObj.ProductId));
            criteria.Add(Restrictions.Eq("GoodIdentificationMvoEventId.ProductGoodIdentificationIdGoodIdentificationTypeId", idObj.GoodIdentificationTypeId));
            criteria.Add(Restrictions.Le("GoodIdentificationMvoEventId.ProductVersion", version));
            criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("GoodIdentificationMvoEventId.ProductVersion"));
            var es = criteria.List <IEvent>();

            foreach (GoodIdentificationMvoEventBase e in es)
            {
                e.EventReadOnly = true;
            }
            return(new EventStream()
            {
                SteamVersion = es.Count > 0 ? ((GoodIdentificationMvoEventBase)es.Last()).GoodIdentificationMvoEventId.ProductVersion : default(long),
                Events = es
            });
        }
Beispiel #2
0
        public static string ToIdString(ProductGoodIdentificationId id)
        {
            var formatter = (new ValueObjectTextFormatter <ProductGoodIdentificationId>());
            var idStr     = formatter.ToString(id);

            return(idStr);
        }
        public IGoodIdentificationMvoState Get(ProductGoodIdentificationId id)
        {
            IGoodIdentificationMvoState state = CurrentSession.Get <GoodIdentificationMvoState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IGoodIdentificationMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Beispiel #4
0
        public async Task <IGoodIdentificationMvoState> GetHistoryStateAsync(ProductGoodIdentificationId productGoodIdentificationId, long version)
        {
            var idObj         = GoodIdentificationMvoProxyUtils.ToIdString(productGoodIdentificationId);
            var uriParameters = new GoodIdentificationMvoHistoryStateUriParameters();

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

            var req  = new GoodIdentificationMvoHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.GoodIdentificationMvoHistoryState.Get(req);

            GoodIdentificationMvoProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToGoodIdentificationMvoState());
        }
Beispiel #5
0
        public async Task <IGoodIdentificationMvoEvent> GetStateEventAsync(ProductGoodIdentificationId productGoodIdentificationId, long version)
        {
            var idObj         = GoodIdentificationMvoProxyUtils.ToIdString(productGoodIdentificationId);
            var uriParameters = new GoodIdentificationMvoStateEventUriParameters();

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

            var req  = new GoodIdentificationMvoStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.GoodIdentificationMvoStateEvent.Get(req);

            GoodIdentificationMvoProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public virtual IGoodIdentificationMvoEvent GetEvent(ProductGoodIdentificationId productGoodIdentificationId, long version)
        {
            var e = (IGoodIdentificationMvoEvent)EventStore.GetEvent(ToEventStoreAggregateId(productGoodIdentificationId), version);

            if (e != null)
            {
                e.ReadOnly = true;
            }
            else if (version == -1)
            {
                return(GetEvent(productGoodIdentificationId, 0));
            }
            return(e);
        }
Beispiel #7
0
        public IGoodIdentificationMvoState Get(ProductGoodIdentificationId id, bool nullAllowed)
        {
            IGoodIdentificationMvoState state = CurrentSession.Get <GoodIdentificationMvoState> (id);

            if (!nullAllowed && state == null)
            {
                state = new GoodIdentificationMvoState();
                (state as GoodIdentificationMvoState).ProductGoodIdentificationId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IGoodIdentificationMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Beispiel #8
0
        public async Task <IGoodIdentificationMvoState> GetAsync(ProductGoodIdentificationId productGoodIdentificationId)
        {
            IGoodIdentificationMvoState state = null;
            var idObj         = GoodIdentificationMvoProxyUtils.ToIdString(productGoodIdentificationId);
            var uriParameters = new GoodIdentificationMvoUriParameters();

            uriParameters.Id = idObj;

            var req = new GoodIdentificationMvoGetRequest(uriParameters);

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

            GoodIdentificationMvoProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToGoodIdentificationMvoState();
            return(state);
        }
Beispiel #9
0
 public virtual IGoodIdentificationMvoState GetHistoryState(ProductGoodIdentificationId productGoodIdentificationId, long version)
 {
     return(GetHistoryStateAsync(productGoodIdentificationId, version).GetAwaiter().GetResult());
 }
Beispiel #10
0
 public IGoodIdentificationMvoEvent GetEvent(ProductGoodIdentificationId productGoodIdentificationId, long version)
 {
     return(GetStateEventAsync(productGoodIdentificationId, version).GetAwaiter().GetResult());
 }
Beispiel #11
0
 public IGoodIdentificationMvoState Get(ProductGoodIdentificationId productGoodIdentificationId)
 {
     return(GetAsync(productGoodIdentificationId).GetAwaiter().GetResult());
 }
Beispiel #12
0
        public virtual IGoodIdentificationState GetGoodIdentification(string productId, string goodIdentificationTypeId)
        {
            var entityId = new ProductGoodIdentificationId(productId, goodIdentificationTypeId);

            return(CurrentSession.Get <GoodIdentificationState>(entityId));
        }
 public abstract IEventStoreAggregateId ToEventStoreAggregateId(ProductGoodIdentificationId aggregateId);
        public virtual IGoodIdentificationMvoState GetHistoryState(ProductGoodIdentificationId productGoodIdentificationId, long version)
        {
            var eventStream = EventStore.LoadEventStream(typeof(IGoodIdentificationMvoEvent), ToEventStoreAggregateId(productGoodIdentificationId), version - 1);

            return(new GoodIdentificationMvoState(eventStream.Events));
        }
        public virtual IGoodIdentificationMvoState Get(ProductGoodIdentificationId productGoodIdentificationId)
        {
            var state = StateRepository.Get(productGoodIdentificationId, true);

            return(state);
        }
Beispiel #16
0
 public override IEventStoreAggregateId ToEventStoreAggregateId(ProductGoodIdentificationId aggregateId)
 {
     return(new EventStoreAggregateId(aggregateId));
 }
 public GoodIdentificationMvoEventId(ProductGoodIdentificationId productGoodIdentificationId, long productVersion)
 {
     this._productGoodIdentificationId = productGoodIdentificationId;
     this._productVersion = productVersion;
 }