public static string ToIdString(UomConversionId id) { var formatter = (new ValueObjectTextFormatter <UomConversionId>()); var idStr = formatter.ToString(id); return(idStr); }
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 }); }
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); }
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()); }
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); }
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); }
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); }
public virtual IUomConversionState GetHistoryState(UomConversionId uomConversionId, long version) { return(GetHistoryStateAsync(uomConversionId, version).GetAwaiter().GetResult()); }
public IUomConversionEvent GetEvent(UomConversionId uomConversionId, long version) { return(GetStateEventAsync(uomConversionId, version).GetAwaiter().GetResult()); }
public IUomConversionState Get(UomConversionId uomConversionId) { return(GetAsync(uomConversionId).GetAwaiter().GetResult()); }
public override IEventStoreAggregateId ToEventStoreAggregateId(UomConversionId aggregateId) { return(new EventStoreAggregateId(aggregateId)); }