Пример #1
0
        }// END Map(ICreate... ////////////////////////////

        protected virtual IOrderShipGroupStateMergePatched MapMergePatch(IMergePatchOrderShipGroup c, IOrderCommand outerCommand, long version, IOrderState outerState)
        {
            c.RequesterId = outerCommand.RequesterId;
            var stateEventId = new OrderShipGroupEventId(c.OrderId, c.ShipGroupSeqId, version);
            IOrderShipGroupStateMergePatched e = NewOrderShipGroupStateMergePatched(stateEventId);
            var s = outerState.OrderShipGroups.Get(c.ShipGroupSeqId);

            e.ShipmentMethodTypeId = c.ShipmentMethodTypeId;
            e.SupplierPartyId      = c.SupplierPartyId;
            e.VendorPartyId        = c.VendorPartyId;
            e.CarrierPartyId       = c.CarrierPartyId;
            e.CarrierRoleTypeId    = c.CarrierRoleTypeId;
            e.FacilityId           = c.FacilityId;
            e.ContactMechId        = c.ContactMechId;
            e.TelecomContactMechId = c.TelecomContactMechId;
            e.TrackingNumber       = c.TrackingNumber;
            e.ShippingInstructions = c.ShippingInstructions;
            e.MaySplit             = c.MaySplit;
            e.GiftMessage          = c.GiftMessage;
            e.IsGift                = c.IsGift;
            e.ShipAfterDate         = c.ShipAfterDate;
            e.ShipByDate            = c.ShipByDate;
            e.EstimatedShipDate     = c.EstimatedShipDate;
            e.EstimatedDeliveryDate = c.EstimatedDeliveryDate;
            e.PickwaveId            = c.PickwaveId;
            e.Active                = c.Active;
            e.IsPropertyShipmentMethodTypeIdRemoved = c.IsPropertyShipmentMethodTypeIdRemoved;
            e.IsPropertySupplierPartyIdRemoved      = c.IsPropertySupplierPartyIdRemoved;
            e.IsPropertyVendorPartyIdRemoved        = c.IsPropertyVendorPartyIdRemoved;
            e.IsPropertyCarrierPartyIdRemoved       = c.IsPropertyCarrierPartyIdRemoved;
            e.IsPropertyCarrierRoleTypeIdRemoved    = c.IsPropertyCarrierRoleTypeIdRemoved;
            e.IsPropertyFacilityIdRemoved           = c.IsPropertyFacilityIdRemoved;
            e.IsPropertyContactMechIdRemoved        = c.IsPropertyContactMechIdRemoved;
            e.IsPropertyTelecomContactMechIdRemoved = c.IsPropertyTelecomContactMechIdRemoved;
            e.IsPropertyTrackingNumberRemoved       = c.IsPropertyTrackingNumberRemoved;
            e.IsPropertyShippingInstructionsRemoved = c.IsPropertyShippingInstructionsRemoved;
            e.IsPropertyMaySplitRemoved             = c.IsPropertyMaySplitRemoved;
            e.IsPropertyGiftMessageRemoved          = c.IsPropertyGiftMessageRemoved;
            e.IsPropertyIsGiftRemoved                = c.IsPropertyIsGiftRemoved;
            e.IsPropertyShipAfterDateRemoved         = c.IsPropertyShipAfterDateRemoved;
            e.IsPropertyShipByDateRemoved            = c.IsPropertyShipByDateRemoved;
            e.IsPropertyEstimatedShipDateRemoved     = c.IsPropertyEstimatedShipDateRemoved;
            e.IsPropertyEstimatedDeliveryDateRemoved = c.IsPropertyEstimatedDeliveryDateRemoved;
            e.IsPropertyPickwaveIdRemoved            = c.IsPropertyPickwaveIdRemoved;
            e.IsPropertyActiveRemoved                = c.IsPropertyActiveRemoved;

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

            foreach (IOrderItemShipGroupAssociationCommand innerCommand in c.OrderItemShipGroupAssociationCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IOrderItemShipGroupAssociationEvent innerEvent = Map(innerCommand, c, version, s);
                e.AddOrderItemShipGroupAssociationEvent(innerEvent);
            }

            return(e);
        }// END Map(IMergePatch... ////////////////////////////
        protected void ThrowOnWrongEvent(IOrderItemShipGroupAssociationEvent e)
        {
            var id = new System.Text.StringBuilder();

            id.Append("[").Append("OrderItemShipGroupAssociation|");

            var stateEntityIdOrderId = (this as IGlobalIdentity <OrderItemShipGroupAssociationId>).GlobalId.OrderId;
            var eventEntityIdOrderId = e.OrderItemShipGroupAssociationEventId.OrderId;

            if (stateEntityIdOrderId != eventEntityIdOrderId)
            {
                throw DomainError.Named("mutateWrongEntity", "Entity Id OrderId {0} in state but entity id OrderId {1} in event", stateEntityIdOrderId, eventEntityIdOrderId);
            }
            id.Append(stateEntityIdOrderId).Append(",");

            var stateEntityIdOrderShipGroupShipGroupSeqId = (this as IGlobalIdentity <OrderItemShipGroupAssociationId>).GlobalId.OrderShipGroupShipGroupSeqId;
            var eventEntityIdOrderShipGroupShipGroupSeqId = e.OrderItemShipGroupAssociationEventId.OrderShipGroupShipGroupSeqId;

            if (stateEntityIdOrderShipGroupShipGroupSeqId != eventEntityIdOrderShipGroupShipGroupSeqId)
            {
                throw DomainError.Named("mutateWrongEntity", "Entity Id OrderShipGroupShipGroupSeqId {0} in state but entity id OrderShipGroupShipGroupSeqId {1} in event", stateEntityIdOrderShipGroupShipGroupSeqId, eventEntityIdOrderShipGroupShipGroupSeqId);
            }
            id.Append(stateEntityIdOrderShipGroupShipGroupSeqId).Append(",");

            var stateEntityIdOrderItemSeqId = (this as IGlobalIdentity <OrderItemShipGroupAssociationId>).GlobalId.OrderItemSeqId;
            var eventEntityIdOrderItemSeqId = e.OrderItemShipGroupAssociationEventId.OrderItemSeqId;

            if (stateEntityIdOrderItemSeqId != eventEntityIdOrderItemSeqId)
            {
                throw DomainError.Named("mutateWrongEntity", "Entity Id OrderItemSeqId {0} in state but entity id OrderItemSeqId {1} in event", stateEntityIdOrderItemSeqId, eventEntityIdOrderItemSeqId);
            }
            id.Append(stateEntityIdOrderItemSeqId).Append(",");

            id.Append("]");

            if (ForReapplying)
            {
                return;
            }
            var stateVersion = this.Version;
            var stateEvent   = e is IOrderItemShipGroupAssociationStateEvent ? (IOrderItemShipGroupAssociationStateEvent)e : null;

            if (e == null)
            {
                return;
            }
            stateEvent.Version = stateVersion;
            //var stateEventStateVersion = stateEvent.Version;
            //if (OrderItemShipGroupAssociationState.VersionZero == stateEventStateVersion)
            //{
            //    stateEventStateVersion = stateEvent.Version = stateVersion;
            //}
            //if (stateVersion != stateEventStateVersion)
            //{
            //    throw OptimisticConcurrencyException.Create(stateVersion, stateEventStateVersion, id.ToString());
            //}
        }
        public void Save(IOrderItemShipGroupAssociationEvent stateEvent)
        {
            CurrentSession.Save(stateEvent);
            var saveable = stateEvent as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
Пример #4
0
 public static void ThrowOnInconsistentEventIds(IOrderShipGroupEvent oe, IOrderItemShipGroupAssociationEvent e)
 {
     if (!oe.OrderShipGroupEventId.OrderId.Equals(e.OrderItemShipGroupAssociationEventId.OrderId))
     {
         throw DomainError.Named("inconsistentEventIds", "Outer Id OrderId {0} but inner id OrderId {1}",
                                 oe.OrderShipGroupEventId.OrderId, e.OrderItemShipGroupAssociationEventId.OrderId);
     }
     if (!oe.OrderShipGroupEventId.ShipGroupSeqId.Equals(e.OrderItemShipGroupAssociationEventId.OrderShipGroupShipGroupSeqId))
     {
         throw DomainError.Named("inconsistentEventIds", "Outer Id ShipGroupSeqId {0} but inner id OrderShipGroupShipGroupSeqId {1}",
                                 oe.OrderShipGroupEventId.ShipGroupSeqId, e.OrderItemShipGroupAssociationEventId.OrderShipGroupShipGroupSeqId);
     }
 }
Пример #5
0
 public virtual void AddOrderItemShipGroupAssociationEvent(IOrderItemShipGroupAssociationEvent e)
 {
     ThrowOnInconsistentEventIds(e);
     this._orderItemShipGroupAssociationEvents[e.OrderItemShipGroupAssociationEventId] = e;
 }
Пример #6
0
 protected void ThrowOnInconsistentEventIds(IOrderItemShipGroupAssociationEvent e)
 {
     ThrowOnInconsistentEventIds(this, e);
 }
Пример #7
0
 public virtual OrderItemShipGroupAssociationStateCreatedOrMergePatchedOrRemovedDto ToOrderItemShipGroupAssociationStateEventDto(IOrderItemShipGroupAssociationEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IOrderItemShipGroupAssociationStateCreated)stateEvent;
         return(ToOrderItemShipGroupAssociationStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IOrderItemShipGroupAssociationStateMergePatched)stateEvent;
         return(ToOrderItemShipGroupAssociationStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Removed)
     {
         var e = (IOrderItemShipGroupAssociationStateRemoved)stateEvent;
         return(ToOrderItemShipGroupAssociationStateRemovedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Пример #8
0
 void IOrderShipGroupStateMergePatched.AddOrderItemShipGroupAssociationEvent(IOrderItemShipGroupAssociationEvent e)
 {
     this._orderItemShipGroupAssociationEvents.AddOrderItemShipGroupAssociationEvent(e);
 }
Пример #9
0
 public void AddOrderItemShipGroupAssociationEvent(IOrderItemShipGroupAssociationEvent e)
 {
     _innerStateEvents.Add((OrderItemShipGroupAssociationStateCreatedOrMergePatchedOrRemovedDto)e);
 }