public static string ToIdString(MovementConfirmationLineId id) { var formatter = (new ValueObjectTextFormatter <MovementConfirmationLineId>()); var idStr = formatter.ToString(id); return(idStr); }
public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version) { Type supportedEventType = typeof(MovementConfirmationLineMvoEventBase); if (!eventType.IsAssignableFrom(supportedEventType)) { throw new NotSupportedException(); } MovementConfirmationLineId idObj = (MovementConfirmationLineId)(eventStoreAggregateId as EventStoreAggregateId).Id; var criteria = CurrentSession.CreateCriteria <MovementConfirmationLineMvoEventBase>(); criteria.Add(Restrictions.Eq("MovementConfirmationLineMvoEventId.MovementConfirmationLineIdMovementConfirmationDocumentNumber", idObj.MovementConfirmationDocumentNumber)); criteria.Add(Restrictions.Eq("MovementConfirmationLineMvoEventId.MovementConfirmationLineIdLineNumber", idObj.LineNumber)); criteria.Add(Restrictions.Le("MovementConfirmationLineMvoEventId.MovementConfirmationVersion", version)); criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("MovementConfirmationLineMvoEventId.MovementConfirmationVersion")); var es = criteria.List <IEvent>(); foreach (MovementConfirmationLineMvoEventBase e in es) { e.EventReadOnly = true; } return(new EventStream() { SteamVersion = es.Count > 0 ? ((MovementConfirmationLineMvoEventBase)es.Last()).MovementConfirmationLineMvoEventId.MovementConfirmationVersion : default(long), Events = es }); }
public IMovementConfirmationLineMvoState Get(MovementConfirmationLineId id) { IMovementConfirmationLineMvoState state = CurrentSession.Get <MovementConfirmationLineMvoState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IMovementConfirmationLineMvoState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IMovementConfirmationLineMvoState> GetHistoryStateAsync(MovementConfirmationLineId movementConfirmationLineId, long version) { var idObj = MovementConfirmationLineMvoProxyUtils.ToIdString(movementConfirmationLineId); var uriParameters = new MovementConfirmationLineMvoHistoryStateUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new MovementConfirmationLineMvoHistoryStateGetRequest(uriParameters); var resp = await _ramlClient.MovementConfirmationLineMvoHistoryState.Get(req); MovementConfirmationLineMvoProxyUtils.ThrowOnHttpResponseError(resp); return((resp.Content == null) ? null : resp.Content.ToMovementConfirmationLineMvoState()); }
public async Task <IMovementConfirmationLineMvoEvent> GetStateEventAsync(MovementConfirmationLineId movementConfirmationLineId, long version) { var idObj = MovementConfirmationLineMvoProxyUtils.ToIdString(movementConfirmationLineId); var uriParameters = new MovementConfirmationLineMvoStateEventUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new MovementConfirmationLineMvoStateEventGetRequest(uriParameters); var resp = await _ramlClient.MovementConfirmationLineMvoStateEvent.Get(req); MovementConfirmationLineMvoProxyUtils.ThrowOnHttpResponseError(resp); return(resp.Content); }
public virtual IMovementConfirmationLineMvoEvent GetEvent(MovementConfirmationLineId movementConfirmationLineId, long version) { var e = (IMovementConfirmationLineMvoEvent)EventStore.GetEvent(ToEventStoreAggregateId(movementConfirmationLineId), version); if (e != null) { e.ReadOnly = true; } else if (version == -1) { return(GetEvent(movementConfirmationLineId, 0)); } return(e); }
public IMovementConfirmationLineState Get(MovementConfirmationLineId id, bool nullAllowed) { IMovementConfirmationLineState state = CurrentSession.Get <MovementConfirmationLineState>(id); if (!nullAllowed && state == null) { state = new MovementConfirmationLineState(); (state as MovementConfirmationLineState).MovementConfirmationLineId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IMovementConfirmationLineState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IMovementConfirmationLineMvoState> GetAsync(MovementConfirmationLineId movementConfirmationLineId) { IMovementConfirmationLineMvoState state = null; var idObj = MovementConfirmationLineMvoProxyUtils.ToIdString(movementConfirmationLineId); var uriParameters = new MovementConfirmationLineMvoUriParameters(); uriParameters.Id = idObj; var req = new MovementConfirmationLineMvoGetRequest(uriParameters); var resp = await _ramlClient.MovementConfirmationLineMvo.Get(req); MovementConfirmationLineMvoProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToMovementConfirmationLineMvoState(); return(state); }
public virtual IMovementConfirmationLineState GetMovementConfirmationLine(string movementConfirmationDocumentNumber, string lineNumber) { var entityId = new MovementConfirmationLineId(movementConfirmationDocumentNumber, lineNumber); return(CurrentSession.Get <MovementConfirmationLineState>(entityId)); }
public override IEventStoreAggregateId ToEventStoreAggregateId(MovementConfirmationLineId aggregateId) { return(new EventStoreAggregateId(aggregateId)); }
public virtual IMovementConfirmationLineMvoState GetHistoryState(MovementConfirmationLineId movementConfirmationLineId, long version) { return(GetHistoryStateAsync(movementConfirmationLineId, version).GetAwaiter().GetResult()); }
public virtual IMovementConfirmationLineMvoState Get(MovementConfirmationLineId movementConfirmationLineId) { var state = StateRepository.Get(movementConfirmationLineId, true); return(state); }
public IMovementConfirmationLineMvoState Get(MovementConfirmationLineId movementConfirmationLineId) { return(GetAsync(movementConfirmationLineId).GetAwaiter().GetResult()); }
public abstract IEventStoreAggregateId ToEventStoreAggregateId(MovementConfirmationLineId aggregateId);
public virtual IMovementConfirmationLineMvoState GetHistoryState(MovementConfirmationLineId movementConfirmationLineId, long version) { var eventStream = EventStore.LoadEventStream(typeof(IMovementConfirmationLineMvoEvent), ToEventStoreAggregateId(movementConfirmationLineId), version - 1); return(new MovementConfirmationLineMvoState(eventStream.Events)); }
public MovementConfirmationLineMvoEventId(MovementConfirmationLineId movementConfirmationLineId, long movementConfirmationVersion) { this._movementConfirmationLineId = movementConfirmationLineId; this._movementConfirmationVersion = movementConfirmationVersion; }
public IMovementConfirmationLineMvoEvent GetEvent(MovementConfirmationLineId movementConfirmationLineId, long version) { return(GetStateEventAsync(movementConfirmationLineId, version).GetAwaiter().GetResult()); }