public static string ToIdString(ShipmentReceiptId id) { var formatter = (new ValueObjectTextFormatter <ShipmentReceiptId>()); var idStr = formatter.ToString(id); return(idStr); }
public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version) { Type supportedEventType = typeof(ShipmentReceiptMvoEventBase); if (!eventType.IsAssignableFrom(supportedEventType)) { throw new NotSupportedException(); } ShipmentReceiptId idObj = (ShipmentReceiptId)(eventStoreAggregateId as EventStoreAggregateId).Id; var criteria = CurrentSession.CreateCriteria <ShipmentReceiptMvoEventBase>(); criteria.Add(Restrictions.Eq("ShipmentReceiptMvoEventId.ShipmentReceiptIdShipmentId", idObj.ShipmentId)); criteria.Add(Restrictions.Eq("ShipmentReceiptMvoEventId.ShipmentReceiptIdReceiptSeqId", idObj.ReceiptSeqId)); criteria.Add(Restrictions.Le("ShipmentReceiptMvoEventId.ShipmentVersion", version)); criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("ShipmentReceiptMvoEventId.ShipmentVersion")); var es = criteria.List <IEvent>(); foreach (ShipmentReceiptMvoEventBase e in es) { e.EventReadOnly = true; } return(new EventStream() { SteamVersion = es.Count > 0 ? ((ShipmentReceiptMvoEventBase)es.Last()).ShipmentReceiptMvoEventId.ShipmentVersion : default(long), Events = es }); }
public IShipmentReceiptMvoState Get(ShipmentReceiptId id) { IShipmentReceiptMvoState state = CurrentSession.Get <ShipmentReceiptMvoState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IShipmentReceiptMvoState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IShipmentReceiptMvoState> GetHistoryStateAsync(ShipmentReceiptId shipmentReceiptId, long version) { var idObj = ShipmentReceiptMvoProxyUtils.ToIdString(shipmentReceiptId); var uriParameters = new ShipmentReceiptMvoHistoryStateUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new ShipmentReceiptMvoHistoryStateGetRequest(uriParameters); var resp = await _ramlClient.ShipmentReceiptMvoHistoryState.Get(req); ShipmentReceiptMvoProxyUtils.ThrowOnHttpResponseError(resp); return((resp.Content == null) ? null : resp.Content.ToShipmentReceiptMvoState()); }
public async Task <IShipmentReceiptMvoEvent> GetStateEventAsync(ShipmentReceiptId shipmentReceiptId, long version) { var idObj = ShipmentReceiptMvoProxyUtils.ToIdString(shipmentReceiptId); var uriParameters = new ShipmentReceiptMvoStateEventUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new ShipmentReceiptMvoStateEventGetRequest(uriParameters); var resp = await _ramlClient.ShipmentReceiptMvoStateEvent.Get(req); ShipmentReceiptMvoProxyUtils.ThrowOnHttpResponseError(resp); return(resp.Content); }
public virtual IShipmentReceiptMvoEvent GetEvent(ShipmentReceiptId shipmentReceiptId, long version) { var e = (IShipmentReceiptMvoEvent)EventStore.GetEvent(ToEventStoreAggregateId(shipmentReceiptId), version); if (e != null) { e.ReadOnly = true; } else if (version == -1) { return(GetEvent(shipmentReceiptId, 0)); } return(e); }
public IShipmentReceiptMvoState Get(ShipmentReceiptId id, bool nullAllowed) { IShipmentReceiptMvoState state = CurrentSession.Get <ShipmentReceiptMvoState> (id); if (!nullAllowed && state == null) { state = new ShipmentReceiptMvoState(); (state as ShipmentReceiptMvoState).ShipmentReceiptId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IShipmentReceiptMvoState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IShipmentReceiptMvoState> GetAsync(ShipmentReceiptId shipmentReceiptId) { IShipmentReceiptMvoState state = null; var idObj = ShipmentReceiptMvoProxyUtils.ToIdString(shipmentReceiptId); var uriParameters = new ShipmentReceiptMvoUriParameters(); uriParameters.Id = idObj; var req = new ShipmentReceiptMvoGetRequest(uriParameters); var resp = await _ramlClient.ShipmentReceiptMvo.Get(req); ShipmentReceiptMvoProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToShipmentReceiptMvoState(); return(state); }
public virtual IShipmentReceiptState GetShipmentReceipt(string shipmentId, string receiptSeqId) { var entityId = new ShipmentReceiptId(shipmentId, receiptSeqId); return(CurrentSession.Get <ShipmentReceiptState>(entityId)); }
public override IEventStoreAggregateId ToEventStoreAggregateId(ShipmentReceiptId aggregateId) { return(new EventStoreAggregateId(aggregateId)); }
public IShipmentReceiptMvoEvent GetEvent(ShipmentReceiptId shipmentReceiptId, long version) { return(GetStateEventAsync(shipmentReceiptId, version).GetAwaiter().GetResult()); }
public ShipmentReceiptMvoEventId(ShipmentReceiptId shipmentReceiptId, long shipmentVersion) { this._shipmentReceiptId = shipmentReceiptId; this._shipmentVersion = shipmentVersion; }
public abstract IEventStoreAggregateId ToEventStoreAggregateId(ShipmentReceiptId aggregateId);
public virtual IShipmentReceiptMvoState GetHistoryState(ShipmentReceiptId shipmentReceiptId, long version) { var eventStream = EventStore.LoadEventStream(typeof(IShipmentReceiptMvoEvent), ToEventStoreAggregateId(shipmentReceiptId), version - 1); return(new ShipmentReceiptMvoState(eventStream.Events)); }
public IShipmentReceiptMvoState Get(ShipmentReceiptId shipmentReceiptId) { return(GetAsync(shipmentReceiptId).GetAwaiter().GetResult()); }
public virtual IShipmentReceiptMvoState Get(ShipmentReceiptId shipmentReceiptId) { var state = StateRepository.Get(shipmentReceiptId, true); return(state); }
public virtual IShipmentReceiptMvoState GetHistoryState(ShipmentReceiptId shipmentReceiptId, long version) { return(GetHistoryStateAsync(shipmentReceiptId, version).GetAwaiter().GetResult()); }