public static string ToIdString(OrderRoleId id) { var formatter = (new ValueObjectTextFormatter <OrderRoleId>()); var idStr = formatter.ToString(id); return(idStr); }
public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version) { Type supportedEventType = typeof(OrderRoleMvoEventBase); if (!eventType.IsAssignableFrom(supportedEventType)) { throw new NotSupportedException(); } OrderRoleId idObj = (OrderRoleId)(eventStoreAggregateId as EventStoreAggregateId).Id; var criteria = CurrentSession.CreateCriteria <OrderRoleMvoEventBase>(); criteria.Add(Restrictions.Eq("OrderRoleMvoEventId.OrderRoleIdOrderId", idObj.OrderId)); criteria.Add(Restrictions.Eq("OrderRoleMvoEventId.OrderRoleIdPartyRoleIdPartyId", idObj.PartyRoleId.PartyId)); criteria.Add(Restrictions.Eq("OrderRoleMvoEventId.OrderRoleIdPartyRoleIdRoleTypeId", idObj.PartyRoleId.RoleTypeId)); criteria.Add(Restrictions.Le("OrderRoleMvoEventId.OrderVersion", version)); criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("OrderRoleMvoEventId.OrderVersion")); var es = criteria.List <IEvent>(); foreach (OrderRoleMvoEventBase e in es) { e.EventReadOnly = true; } return(new EventStream() { SteamVersion = es.Count > 0 ? ((OrderRoleMvoEventBase)es.Last()).OrderRoleMvoEventId.OrderVersion : default(long), Events = es }); }
public IOrderRoleMvoState Get(OrderRoleId id) { IOrderRoleMvoState state = CurrentSession.Get <OrderRoleMvoState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IOrderRoleMvoState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public virtual IOrderRoleMvoEvent GetEvent(OrderRoleId orderRoleId, long version) { var e = (IOrderRoleMvoEvent)EventStore.GetEvent(ToEventStoreAggregateId(orderRoleId), version); if (e != null) { e.ReadOnly = true; } else if (version == -1) { return(GetEvent(orderRoleId, 0)); } return(e); }
public async Task <IOrderRoleMvoState> GetHistoryStateAsync(OrderRoleId orderRoleId, long version) { var idObj = OrderRoleMvoProxyUtils.ToIdString(orderRoleId); var uriParameters = new OrderRoleMvoHistoryStateUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new OrderRoleMvoHistoryStateGetRequest(uriParameters); var resp = await _ramlClient.OrderRoleMvoHistoryState.Get(req); OrderRoleMvoProxyUtils.ThrowOnHttpResponseError(resp); return((resp.Content == null) ? null : resp.Content.ToOrderRoleMvoState()); }
public async Task <IOrderRoleMvoEvent> GetStateEventAsync(OrderRoleId orderRoleId, long version) { var idObj = OrderRoleMvoProxyUtils.ToIdString(orderRoleId); var uriParameters = new OrderRoleMvoStateEventUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new OrderRoleMvoStateEventGetRequest(uriParameters); var resp = await _ramlClient.OrderRoleMvoStateEvent.Get(req); OrderRoleMvoProxyUtils.ThrowOnHttpResponseError(resp); return(resp.Content); }
public IOrderRoleMvoState Get(OrderRoleId id, bool nullAllowed) { IOrderRoleMvoState state = CurrentSession.Get <OrderRoleMvoState> (id); if (!nullAllowed && state == null) { state = new OrderRoleMvoState(); (state as OrderRoleMvoState).OrderRoleId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IOrderRoleMvoState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IOrderRoleMvoState> GetAsync(OrderRoleId orderRoleId) { IOrderRoleMvoState state = null; var idObj = OrderRoleMvoProxyUtils.ToIdString(orderRoleId); var uriParameters = new OrderRoleMvoUriParameters(); uriParameters.Id = idObj; var req = new OrderRoleMvoGetRequest(uriParameters); var resp = await _ramlClient.OrderRoleMvo.Get(req); OrderRoleMvoProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToOrderRoleMvoState(); return(state); }
public override IEventStoreAggregateId ToEventStoreAggregateId(OrderRoleId aggregateId) { return(new EventStoreAggregateId(aggregateId)); }
public abstract IEventStoreAggregateId ToEventStoreAggregateId(OrderRoleId aggregateId);
public virtual IOrderRoleMvoState GetHistoryState(OrderRoleId orderRoleId, long version) { var eventStream = EventStore.LoadEventStream(typeof(IOrderRoleMvoEvent), ToEventStoreAggregateId(orderRoleId), version - 1); return(new OrderRoleMvoState(eventStream.Events)); }
public virtual IOrderRoleMvoState GetHistoryState(OrderRoleId orderRoleId, long version) { return(GetHistoryStateAsync(orderRoleId, version).GetAwaiter().GetResult()); }
public IOrderRoleMvoEvent GetEvent(OrderRoleId orderRoleId, long version) { return(GetStateEventAsync(orderRoleId, version).GetAwaiter().GetResult()); }
public IOrderRoleMvoState Get(OrderRoleId orderRoleId) { return(GetAsync(orderRoleId).GetAwaiter().GetResult()); }
public virtual IOrderRoleMvoState Get(OrderRoleId orderRoleId) { var state = StateRepository.Get(orderRoleId, true); return(state); }
public virtual IOrderRoleState GetOrderRole(string orderId, PartyRoleId partyRoleId) { var entityId = new OrderRoleId(orderId, partyRoleId); return(CurrentSession.Get <OrderRoleState>(entityId)); }
public OrderRoleMvoEventId(OrderRoleId orderRoleId, long orderVersion) { this._orderRoleId = orderRoleId; this._orderVersion = orderVersion; }