예제 #1
0
        public static string ToIdString(UomConversionId id)
        {
            var formatter = (new ValueObjectTextFormatter <UomConversionId>());
            var idStr     = formatter.ToString(id);

            return(idStr);
        }
예제 #2
0
        public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version)
        {
            Type supportedEventType = typeof(UomConversionEventBase);

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

            criteria.Add(Restrictions.Eq("UomConversionEventId.UomConversionIdUomId", idObj.UomId));
            criteria.Add(Restrictions.Eq("UomConversionEventId.UomConversionIdUomIdTo", idObj.UomIdTo));
            criteria.Add(Restrictions.Le("UomConversionEventId.Version", version));
            criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("UomConversionEventId.Version"));
            var es = criteria.List <IEvent>();

            foreach (UomConversionEventBase e in es)
            {
                e.EventReadOnly = true;
            }
            return(new EventStream()
            {
                SteamVersion = es.Count > 0 ? ((UomConversionEventBase)es.Last()).UomConversionEventId.Version : default(long),
                Events = es
            });
        }
예제 #3
0
        public IUomConversionState Get(UomConversionId id)
        {
            IUomConversionState state = CurrentSession.Get <UomConversionState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IUomConversionState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
예제 #4
0
        public async Task <IUomConversionState> GetHistoryStateAsync(UomConversionId uomConversionId, long version)
        {
            var idObj         = UomConversionProxyUtils.ToIdString(uomConversionId);
            var uriParameters = new UomConversionHistoryStateUriParameters();

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

            var req  = new UomConversionHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.UomConversionHistoryState.Get(req);

            UomConversionProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToUomConversionState());
        }
예제 #5
0
        public async Task <IUomConversionEvent> GetStateEventAsync(UomConversionId uomConversionId, long version)
        {
            var idObj         = UomConversionProxyUtils.ToIdString(uomConversionId);
            var uriParameters = new UomConversionStateEventUriParameters();

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

            var req  = new UomConversionStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.UomConversionStateEvent.Get(req);

            UomConversionProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
예제 #6
0
        public IUomConversionState Get(UomConversionId id, bool nullAllowed)
        {
            IUomConversionState state = CurrentSession.Get <UomConversionState> (id);

            if (!nullAllowed && state == null)
            {
                state = new UomConversionState();
                (state as UomConversionState).UomConversionId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IUomConversionState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
예제 #7
0
        public async Task <IUomConversionState> GetAsync(UomConversionId uomConversionId)
        {
            IUomConversionState state = null;
            var idObj         = UomConversionProxyUtils.ToIdString(uomConversionId);
            var uriParameters = new UomConversionUriParameters();

            uriParameters.Id = idObj;

            var req = new UomConversionGetRequest(uriParameters);

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

            UomConversionProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToUomConversionState();
            return(state);
        }
예제 #8
0
 public virtual IUomConversionState GetHistoryState(UomConversionId uomConversionId, long version)
 {
     return(GetHistoryStateAsync(uomConversionId, version).GetAwaiter().GetResult());
 }
예제 #9
0
 public IUomConversionEvent GetEvent(UomConversionId uomConversionId, long version)
 {
     return(GetStateEventAsync(uomConversionId, version).GetAwaiter().GetResult());
 }
예제 #10
0
 public IUomConversionState Get(UomConversionId uomConversionId)
 {
     return(GetAsync(uomConversionId).GetAwaiter().GetResult());
 }
 public override IEventStoreAggregateId ToEventStoreAggregateId(UomConversionId aggregateId)
 {
     return(new EventStoreAggregateId(aggregateId));
 }