public static string ToIdString(OrderShipGroupId id) { var formatter = (new ValueObjectTextFormatter <OrderShipGroupId>()); var idStr = formatter.ToString(id); return(idStr); }
public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version) { Type supportedEventType = typeof(OrderShipGroupMvoEventBase); if (!eventType.IsAssignableFrom(supportedEventType)) { throw new NotSupportedException(); } OrderShipGroupId idObj = (OrderShipGroupId)(eventStoreAggregateId as EventStoreAggregateId).Id; var criteria = CurrentSession.CreateCriteria <OrderShipGroupMvoEventBase>(); criteria.Add(Restrictions.Eq("OrderShipGroupMvoEventId.OrderShipGroupIdOrderId", idObj.OrderId)); criteria.Add(Restrictions.Eq("OrderShipGroupMvoEventId.OrderShipGroupIdShipGroupSeqId", idObj.ShipGroupSeqId)); criteria.Add(Restrictions.Le("OrderShipGroupMvoEventId.OrderVersion", version)); criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("OrderShipGroupMvoEventId.OrderVersion")); var es = criteria.List <IEvent>(); foreach (OrderShipGroupMvoEventBase e in es) { e.EventReadOnly = true; } return(new EventStream() { SteamVersion = es.Count > 0 ? ((OrderShipGroupMvoEventBase)es.Last()).OrderShipGroupMvoEventId.OrderVersion : default(long), Events = es }); }
public IOrderShipGroupMvoState Get(OrderShipGroupId id) { IOrderShipGroupMvoState state = CurrentSession.Get <OrderShipGroupMvoState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IOrderShipGroupMvoState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public virtual IOrderShipGroupMvoEvent GetEvent(OrderShipGroupId orderShipGroupId, long version) { var e = (IOrderShipGroupMvoEvent)EventStore.GetEvent(ToEventStoreAggregateId(orderShipGroupId), version); if (e != null) { e.ReadOnly = true; } else if (version == -1) { return(GetEvent(orderShipGroupId, 0)); } return(e); }
public async Task <IOrderShipGroupMvoState> GetHistoryStateAsync(OrderShipGroupId orderShipGroupId, long version) { var idObj = OrderShipGroupMvoProxyUtils.ToIdString(orderShipGroupId); var uriParameters = new OrderShipGroupMvoHistoryStateUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new OrderShipGroupMvoHistoryStateGetRequest(uriParameters); var resp = await _ramlClient.OrderShipGroupMvoHistoryState.Get(req); OrderShipGroupMvoProxyUtils.ThrowOnHttpResponseError(resp); return((resp.Content == null) ? null : resp.Content.ToOrderShipGroupMvoState()); }
public async Task <IOrderShipGroupMvoEvent> GetStateEventAsync(OrderShipGroupId orderShipGroupId, long version) { var idObj = OrderShipGroupMvoProxyUtils.ToIdString(orderShipGroupId); var uriParameters = new OrderShipGroupMvoStateEventUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new OrderShipGroupMvoStateEventGetRequest(uriParameters); var resp = await _ramlClient.OrderShipGroupMvoStateEvent.Get(req); OrderShipGroupMvoProxyUtils.ThrowOnHttpResponseError(resp); return(resp.Content); }
public IOrderShipGroupState Get(OrderShipGroupId id, bool nullAllowed) { IOrderShipGroupState state = CurrentSession.Get <OrderShipGroupState>(id); if (!nullAllowed && state == null) { state = new OrderShipGroupState(); (state as OrderShipGroupState).OrderShipGroupId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IOrderShipGroupState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public async Task <IOrderShipGroupMvoState> GetAsync(OrderShipGroupId orderShipGroupId) { IOrderShipGroupMvoState state = null; var idObj = OrderShipGroupMvoProxyUtils.ToIdString(orderShipGroupId); var uriParameters = new OrderShipGroupMvoUriParameters(); uriParameters.Id = idObj; var req = new OrderShipGroupMvoGetRequest(uriParameters); var resp = await _ramlClient.OrderShipGroupMvo.Get(req); OrderShipGroupMvoProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToOrderShipGroupMvoState(); return(state); }
public void OrderShipGroupAction(string orderId, string shipGroupSeqId, [FromBody] OrderCommandDtos.OrderShipGroupActionRequestContent content) { try { var cmd = content.ToOrderShipGroupAction(); var idObj = new OrderShipGroupId(orderId, shipGroupSeqId); if (cmd.OrderShipGroupId == null) { cmd.OrderShipGroupId = idObj; } else if (!cmd.OrderShipGroupId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", idObj, cmd.OrderShipGroupId); } _orderApplicationService.When(cmd); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
public virtual IOrderShipGroupMvoState GetHistoryState(OrderShipGroupId orderShipGroupId, long version) { var eventStream = EventStore.LoadEventStream(typeof(IOrderShipGroupMvoEvent), ToEventStoreAggregateId(orderShipGroupId), version - 1); return(new OrderShipGroupMvoState(eventStream.Events)); }
public virtual IOrderShipGroupMvoState Get(OrderShipGroupId orderShipGroupId) { var state = StateRepository.Get(orderShipGroupId, true); return(state); }
public override IEventStoreAggregateId ToEventStoreAggregateId(OrderShipGroupId aggregateId) { return(new EventStoreAggregateId(aggregateId)); }
public IOrderShipGroupMvoEvent GetEvent(OrderShipGroupId orderShipGroupId, long version) { return(GetStateEventAsync(orderShipGroupId, version).GetAwaiter().GetResult()); }
public IOrderShipGroupMvoState Get(OrderShipGroupId orderShipGroupId) { return(GetAsync(orderShipGroupId).GetAwaiter().GetResult()); }
public OrderShipGroupMvoEventId(OrderShipGroupId orderShipGroupId, long orderVersion) { this._orderShipGroupId = orderShipGroupId; this._orderVersion = orderVersion; }
public abstract IEventStoreAggregateId ToEventStoreAggregateId(OrderShipGroupId aggregateId);
public virtual IOrderShipGroupState GetOrderShipGroup(string orderId, string shipGroupSeqId) { var entityId = new OrderShipGroupId(orderId, shipGroupSeqId); return(CurrentSession.Get <OrderShipGroupState>(entityId)); }
public virtual IOrderShipGroupMvoState GetHistoryState(OrderShipGroupId orderShipGroupId, long version) { return(GetHistoryStateAsync(orderShipGroupId, version).GetAwaiter().GetResult()); }