Пример #1
0
        public virtual void Initialize(IShipmentStateCreated stateCreated)
        {
            var aggregateId = stateCreated.ShipmentEventId.ShipmentId;
            var state       = new ShipmentState();

            state.ShipmentId = aggregateId;
            var aggregate = (ShipmentAggregate)GetShipmentAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Пример #2
0
        public virtual void When(IShipmentStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.ShipmentTypeId = e.ShipmentTypeId;

            this.StatusId = e.StatusId;

            this.PrimaryOrderId = e.PrimaryOrderId;

            this.PrimaryReturnId = e.PrimaryReturnId;

            this.PrimaryShipGroupSeqId = e.PrimaryShipGroupSeqId;

            this.PicklistBinId = e.PicklistBinId;

            this.BolNumber = e.BolNumber;

            this.SealNumber = e.SealNumber;

            this.VehicleId = e.VehicleId;

            this.ExternalOrderNumber = e.ExternalOrderNumber;

            this.Carrier = e.Carrier;

            this.DateShipped = e.DateShipped;

            this.EstimatedReadyDate = e.EstimatedReadyDate;

            this.EstimatedShipDate = e.EstimatedShipDate;

            this.EstimatedShipWorkEffId = e.EstimatedShipWorkEffId;

            this.EstimatedArrivalDate = e.EstimatedArrivalDate;

            this.EstimatedArrivalWorkEffId = e.EstimatedArrivalWorkEffId;

            this.LatestCancelDate = e.LatestCancelDate;

            this.EstimatedShipCost = e.EstimatedShipCost;

            this.CurrencyUomId = e.CurrencyUomId;

            this.HandlingInstructions = e.HandlingInstructions;

            this.OriginFacilityId = e.OriginFacilityId;

            this.DestinationFacilityId = e.DestinationFacilityId;

            this.OriginContactMechId = e.OriginContactMechId;

            this.OriginTelecomNumberId = e.OriginTelecomNumberId;

            this.DestinationContactMechId = e.DestinationContactMechId;

            this.DestinationTelecomNumberId = e.DestinationTelecomNumberId;

            this.PartyIdTo = e.PartyIdTo;

            this.PartyIdFrom = e.PartyIdFrom;

            this.AdditionalShippingCharge = e.AdditionalShippingCharge;

            this.AddtlShippingChargeDesc = e.AddtlShippingChargeDesc;

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

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;

            foreach (IShipmentImageStateCreated innerEvent in e.ShipmentImageEvents)
            {
                IShipmentImageState innerState = this.ShipmentImages.Get(innerEvent.GlobalId.SequenceId, true);
                innerState.Mutate(innerEvent);
            }
            foreach (IShipmentItemStateCreated innerEvent in e.ShipmentItemEvents)
            {
                IShipmentItemState innerState = this.ShipmentItems.Get(innerEvent.GlobalId.ShipmentItemSeqId, true);
                innerState.Mutate(innerEvent);
            }
            foreach (IShipmentReceiptStateCreated innerEvent in e.ShipmentReceiptEvents)
            {
                IShipmentReceiptState innerState = this.ShipmentReceipts.Get(innerEvent.GlobalId.ReceiptSeqId, true);
                innerState.Mutate(innerEvent);
            }
            foreach (IItemIssuanceStateCreated innerEvent in e.ItemIssuanceEvents)
            {
                IItemIssuanceState innerState = this.ItemIssuances.Get(innerEvent.GlobalId.ItemIssuanceSeqId, true);
                innerState.Mutate(innerEvent);
            }
        }
Пример #3
0
        public virtual ShipmentStateCreatedDto ToShipmentStateCreatedDto(IShipmentStateCreated e)
        {
            var dto = new ShipmentStateCreatedDto();

            dto.ShipmentEventId       = e.ShipmentEventId;
            dto.CreatedAt             = e.CreatedAt;
            dto.CreatedBy             = e.CreatedBy;
            dto.CommandId             = e.CommandId;
            dto.ShipmentTypeId        = e.ShipmentTypeId;
            dto.StatusId              = e.StatusId;
            dto.PrimaryOrderId        = e.PrimaryOrderId;
            dto.PrimaryReturnId       = e.PrimaryReturnId;
            dto.PrimaryShipGroupSeqId = e.PrimaryShipGroupSeqId;
            dto.PicklistBinId         = e.PicklistBinId;
            dto.BolNumber             = e.BolNumber;
            dto.SealNumber            = e.SealNumber;
            dto.VehicleId             = e.VehicleId;
            dto.ExternalOrderNumber   = e.ExternalOrderNumber;
            dto.Carrier                    = e.Carrier;
            dto.DateShipped                = e.DateShipped;
            dto.EstimatedReadyDate         = e.EstimatedReadyDate;
            dto.EstimatedShipDate          = e.EstimatedShipDate;
            dto.EstimatedShipWorkEffId     = e.EstimatedShipWorkEffId;
            dto.EstimatedArrivalDate       = e.EstimatedArrivalDate;
            dto.EstimatedArrivalWorkEffId  = e.EstimatedArrivalWorkEffId;
            dto.LatestCancelDate           = e.LatestCancelDate;
            dto.EstimatedShipCost          = e.EstimatedShipCost;
            dto.CurrencyUomId              = e.CurrencyUomId;
            dto.HandlingInstructions       = e.HandlingInstructions;
            dto.OriginFacilityId           = e.OriginFacilityId;
            dto.DestinationFacilityId      = e.DestinationFacilityId;
            dto.OriginContactMechId        = e.OriginContactMechId;
            dto.OriginTelecomNumberId      = e.OriginTelecomNumberId;
            dto.DestinationContactMechId   = e.DestinationContactMechId;
            dto.DestinationTelecomNumberId = e.DestinationTelecomNumberId;
            dto.PartyIdTo                  = e.PartyIdTo;
            dto.PartyIdFrom                = e.PartyIdFrom;
            dto.AdditionalShippingCharge   = e.AdditionalShippingCharge;
            dto.AddtlShippingChargeDesc    = e.AddtlShippingChargeDesc;
            dto.Active = e.Active;
            var shipmentImageEvents = new List <ShipmentImageStateCreatedDto>();

            foreach (var ee in e.ShipmentImageEvents)
            {
                ShipmentImageStateCreatedDto eeDto = ShipmentImageStateEventDtoConverter.ToShipmentImageStateCreatedDto(ee);
                shipmentImageEvents.Add(eeDto);
            }
            dto.ShipmentImageEvents = shipmentImageEvents.ToArray();

            var shipmentItemEvents = new List <ShipmentItemStateCreatedDto>();

            foreach (var ee in e.ShipmentItemEvents)
            {
                ShipmentItemStateCreatedDto eeDto = ShipmentItemStateEventDtoConverter.ToShipmentItemStateCreatedDto(ee);
                shipmentItemEvents.Add(eeDto);
            }
            dto.ShipmentItemEvents = shipmentItemEvents.ToArray();

            var shipmentReceiptEvents = new List <ShipmentReceiptStateCreatedDto>();

            foreach (var ee in e.ShipmentReceiptEvents)
            {
                ShipmentReceiptStateCreatedDto eeDto = ShipmentReceiptStateEventDtoConverter.ToShipmentReceiptStateCreatedDto(ee);
                shipmentReceiptEvents.Add(eeDto);
            }
            dto.ShipmentReceiptEvents = shipmentReceiptEvents.ToArray();

            var itemIssuanceEvents = new List <ItemIssuanceStateCreatedDto>();

            foreach (var ee in e.ItemIssuanceEvents)
            {
                ItemIssuanceStateCreatedDto eeDto = ItemIssuanceStateEventDtoConverter.ToItemIssuanceStateCreatedDto(ee);
                itemIssuanceEvents.Add(eeDto);
            }
            dto.ItemIssuanceEvents = itemIssuanceEvents.ToArray();

            return(dto);
        }
Пример #4
0
        protected virtual IShipmentStateCreated Map(ICreateShipment c)
        {
            var stateEventId        = new ShipmentEventId(c.ShipmentId, c.Version);
            IShipmentStateCreated e = NewShipmentStateCreated(stateEventId);

            e.ShipmentTypeId        = c.ShipmentTypeId;
            e.StatusId              = c.StatusId;
            e.PrimaryOrderId        = c.PrimaryOrderId;
            e.PrimaryReturnId       = c.PrimaryReturnId;
            e.PrimaryShipGroupSeqId = c.PrimaryShipGroupSeqId;
            e.PicklistBinId         = c.PicklistBinId;
            e.BolNumber             = c.BolNumber;
            e.SealNumber            = c.SealNumber;
            e.VehicleId             = c.VehicleId;
            e.ExternalOrderNumber   = c.ExternalOrderNumber;
            e.Carrier                    = c.Carrier;
            e.DateShipped                = c.DateShipped;
            e.EstimatedReadyDate         = c.EstimatedReadyDate;
            e.EstimatedShipDate          = c.EstimatedShipDate;
            e.EstimatedShipWorkEffId     = c.EstimatedShipWorkEffId;
            e.EstimatedArrivalDate       = c.EstimatedArrivalDate;
            e.EstimatedArrivalWorkEffId  = c.EstimatedArrivalWorkEffId;
            e.LatestCancelDate           = c.LatestCancelDate;
            e.EstimatedShipCost          = c.EstimatedShipCost;
            e.CurrencyUomId              = c.CurrencyUomId;
            e.HandlingInstructions       = c.HandlingInstructions;
            e.OriginFacilityId           = c.OriginFacilityId;
            e.DestinationFacilityId      = c.DestinationFacilityId;
            e.OriginContactMechId        = c.OriginContactMechId;
            e.OriginTelecomNumberId      = c.OriginTelecomNumberId;
            e.DestinationContactMechId   = c.DestinationContactMechId;
            e.DestinationTelecomNumberId = c.DestinationTelecomNumberId;
            e.PartyIdTo                  = c.PartyIdTo;
            e.PartyIdFrom                = c.PartyIdFrom;
            e.AdditionalShippingCharge   = c.AdditionalShippingCharge;
            e.AddtlShippingChargeDesc    = c.AddtlShippingChargeDesc;
            e.Active    = c.Active;
            e.CommandId = c.CommandId;


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

            foreach (ICreateShipmentImage innerCommand in c.ShipmentImages)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IShipmentImageStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddShipmentImageEvent(innerEvent);
            }

            foreach (ICreateShipmentItem innerCommand in c.ShipmentItems)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IShipmentItemStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddShipmentItemEvent(innerEvent);
            }

            foreach (ICreateShipmentReceipt innerCommand in c.ShipmentReceipts)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IShipmentReceiptStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddShipmentReceiptEvent(innerEvent);
            }

            foreach (ICreateItemIssuance innerCommand in c.ItemIssuances)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IItemIssuanceStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddItemIssuanceEvent(innerEvent);
            }


            return(e);
        }
Пример #5
0
        public virtual void Create(ICreateShipment c)
        {
            IShipmentStateCreated e = Map(c);

            Apply(e);
        }
Пример #6
0
 void IShipmentState.When(IShipmentStateCreated e)
 {
     throw new NotSupportedException();
 }