示例#1
0
        public virtual void When(IOrderShipmentStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Quantity = e.Quantity;

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
示例#2
0
        public virtual OrderShipmentStateCreatedDto ToOrderShipmentStateCreatedDto(IOrderShipmentStateCreated e)
        {
            var dto = new OrderShipmentStateCreatedDto();

            dto.OrderShipmentEventId = e.OrderShipmentEventId;
            dto.CreatedAt            = e.CreatedAt;
            dto.CreatedBy            = e.CreatedBy;
            dto.CommandId            = e.CommandId;
            dto.Quantity             = e.Quantity;
            dto.Active = e.Active;
            return(dto);
        }
        public virtual void Initialize(IOrderShipmentStateCreated stateCreated)
        {
            var aggregateId = stateCreated.OrderShipmentEventId.OrderShipmentId;
            var state       = new OrderShipmentState();

            state.OrderShipmentId = aggregateId;
            var aggregate = (OrderShipmentAggregate)GetOrderShipmentAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
示例#4
0
        protected virtual IOrderShipmentStateCreated Map(ICreateOrderShipment c)
        {
            var stateEventId             = new OrderShipmentEventId(c.OrderShipmentId, c.Version);
            IOrderShipmentStateCreated e = NewOrderShipmentStateCreated(stateEventId);

            e.Quantity  = c.Quantity;
            e.Active    = c.Active;
            e.CommandId = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            var version = c.Version;


            return(e);
        }
示例#5
0
        public virtual void Create(ICreateOrderShipment c)
        {
            IOrderShipmentStateCreated e = Map(c);

            Apply(e);
        }
 void IOrderShipmentState.When(IOrderShipmentStateCreated e)
 {
     throw new NotSupportedException();
 }