Exemplo n.º 1
0
        public static TRemoveShipmentItem ToRemoveShipmentItem <TRemoveShipmentItem>(this IShipmentItemState state)
            where TRemoveShipmentItem : IRemoveShipmentItem, new()
        {
            var cmd = new TRemoveShipmentItem();

            cmd.ShipmentItemSeqId = state.ShipmentItemSeqId;
            return(cmd);
        }
Exemplo n.º 2
0
        public static TCreateShipmentItem ToCreateShipmentItem <TCreateShipmentItem>(this IShipmentItemState state)
            where TCreateShipmentItem : ICreateShipmentItem, new()
        {
            var cmd = new TCreateShipmentItem();

            cmd.ShipmentItemSeqId      = state.ShipmentItemSeqId;
            cmd.ProductId              = state.ProductId;
            cmd.AttributeSetInstanceId = state.AttributeSetInstanceId;
            cmd.Quantity = state.Quantity;
            cmd.ShipmentContentDescription = state.ShipmentContentDescription;
            cmd.Active     = ((IShipmentItemStateProperties)state).Active;
            cmd.ShipmentId = state.ShipmentId;
            return(cmd);
        }
        public IShipmentItemState Get(ShipmentItemId id, bool nullAllowed)
        {
            IShipmentItemState state = CurrentSession.Get <ShipmentItemState>(id);

            if (!nullAllowed && state == null)
            {
                state = new ShipmentItemState();
                (state as ShipmentItemState).ShipmentItemId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IShipmentItemState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public void Delete(IShipmentItemState state)
        {
            IShipmentItemState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IShipmentItemState>(state);
            }
            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Delete(s);
        }
Exemplo n.º 5
0
        public virtual void When(IShipmentStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.ShipmentTypeId == null)
            {
                if (e.IsPropertyShipmentTypeIdRemoved)
                {
                    this.ShipmentTypeId = default(string);
                }
            }
            else
            {
                this.ShipmentTypeId = e.ShipmentTypeId;
            }

            if (e.StatusId == null)
            {
                if (e.IsPropertyStatusIdRemoved)
                {
                    this.StatusId = default(string);
                }
            }
            else
            {
                this.StatusId = e.StatusId;
            }

            if (e.PrimaryOrderId == null)
            {
                if (e.IsPropertyPrimaryOrderIdRemoved)
                {
                    this.PrimaryOrderId = default(string);
                }
            }
            else
            {
                this.PrimaryOrderId = e.PrimaryOrderId;
            }

            if (e.PrimaryReturnId == null)
            {
                if (e.IsPropertyPrimaryReturnIdRemoved)
                {
                    this.PrimaryReturnId = default(string);
                }
            }
            else
            {
                this.PrimaryReturnId = e.PrimaryReturnId;
            }

            if (e.PrimaryShipGroupSeqId == null)
            {
                if (e.IsPropertyPrimaryShipGroupSeqIdRemoved)
                {
                    this.PrimaryShipGroupSeqId = default(string);
                }
            }
            else
            {
                this.PrimaryShipGroupSeqId = e.PrimaryShipGroupSeqId;
            }

            if (e.PicklistBinId == null)
            {
                if (e.IsPropertyPicklistBinIdRemoved)
                {
                    this.PicklistBinId = default(string);
                }
            }
            else
            {
                this.PicklistBinId = e.PicklistBinId;
            }

            if (e.BolNumber == null)
            {
                if (e.IsPropertyBolNumberRemoved)
                {
                    this.BolNumber = default(string);
                }
            }
            else
            {
                this.BolNumber = e.BolNumber;
            }

            if (e.SealNumber == null)
            {
                if (e.IsPropertySealNumberRemoved)
                {
                    this.SealNumber = default(string);
                }
            }
            else
            {
                this.SealNumber = e.SealNumber;
            }

            if (e.VehicleId == null)
            {
                if (e.IsPropertyVehicleIdRemoved)
                {
                    this.VehicleId = default(string);
                }
            }
            else
            {
                this.VehicleId = e.VehicleId;
            }

            if (e.ExternalOrderNumber == null)
            {
                if (e.IsPropertyExternalOrderNumberRemoved)
                {
                    this.ExternalOrderNumber = default(string);
                }
            }
            else
            {
                this.ExternalOrderNumber = e.ExternalOrderNumber;
            }

            if (e.Carrier == null)
            {
                if (e.IsPropertyCarrierRemoved)
                {
                    this.Carrier = default(string);
                }
            }
            else
            {
                this.Carrier = e.Carrier;
            }

            if (e.DateShipped == null)
            {
                if (e.IsPropertyDateShippedRemoved)
                {
                    this.DateShipped = default(DateTime?);
                }
            }
            else
            {
                this.DateShipped = e.DateShipped;
            }

            if (e.EstimatedReadyDate == null)
            {
                if (e.IsPropertyEstimatedReadyDateRemoved)
                {
                    this.EstimatedReadyDate = default(DateTime?);
                }
            }
            else
            {
                this.EstimatedReadyDate = e.EstimatedReadyDate;
            }

            if (e.EstimatedShipDate == null)
            {
                if (e.IsPropertyEstimatedShipDateRemoved)
                {
                    this.EstimatedShipDate = default(DateTime?);
                }
            }
            else
            {
                this.EstimatedShipDate = e.EstimatedShipDate;
            }

            if (e.EstimatedShipWorkEffId == null)
            {
                if (e.IsPropertyEstimatedShipWorkEffIdRemoved)
                {
                    this.EstimatedShipWorkEffId = default(string);
                }
            }
            else
            {
                this.EstimatedShipWorkEffId = e.EstimatedShipWorkEffId;
            }

            if (e.EstimatedArrivalDate == null)
            {
                if (e.IsPropertyEstimatedArrivalDateRemoved)
                {
                    this.EstimatedArrivalDate = default(DateTime?);
                }
            }
            else
            {
                this.EstimatedArrivalDate = e.EstimatedArrivalDate;
            }

            if (e.EstimatedArrivalWorkEffId == null)
            {
                if (e.IsPropertyEstimatedArrivalWorkEffIdRemoved)
                {
                    this.EstimatedArrivalWorkEffId = default(string);
                }
            }
            else
            {
                this.EstimatedArrivalWorkEffId = e.EstimatedArrivalWorkEffId;
            }

            if (e.LatestCancelDate == null)
            {
                if (e.IsPropertyLatestCancelDateRemoved)
                {
                    this.LatestCancelDate = default(DateTime?);
                }
            }
            else
            {
                this.LatestCancelDate = e.LatestCancelDate;
            }

            if (e.EstimatedShipCost == null)
            {
                if (e.IsPropertyEstimatedShipCostRemoved)
                {
                    this.EstimatedShipCost = default(decimal?);
                }
            }
            else
            {
                this.EstimatedShipCost = e.EstimatedShipCost;
            }

            if (e.CurrencyUomId == null)
            {
                if (e.IsPropertyCurrencyUomIdRemoved)
                {
                    this.CurrencyUomId = default(string);
                }
            }
            else
            {
                this.CurrencyUomId = e.CurrencyUomId;
            }

            if (e.HandlingInstructions == null)
            {
                if (e.IsPropertyHandlingInstructionsRemoved)
                {
                    this.HandlingInstructions = default(string);
                }
            }
            else
            {
                this.HandlingInstructions = e.HandlingInstructions;
            }

            if (e.OriginFacilityId == null)
            {
                if (e.IsPropertyOriginFacilityIdRemoved)
                {
                    this.OriginFacilityId = default(string);
                }
            }
            else
            {
                this.OriginFacilityId = e.OriginFacilityId;
            }

            if (e.DestinationFacilityId == null)
            {
                if (e.IsPropertyDestinationFacilityIdRemoved)
                {
                    this.DestinationFacilityId = default(string);
                }
            }
            else
            {
                this.DestinationFacilityId = e.DestinationFacilityId;
            }

            if (e.OriginContactMechId == null)
            {
                if (e.IsPropertyOriginContactMechIdRemoved)
                {
                    this.OriginContactMechId = default(string);
                }
            }
            else
            {
                this.OriginContactMechId = e.OriginContactMechId;
            }

            if (e.OriginTelecomNumberId == null)
            {
                if (e.IsPropertyOriginTelecomNumberIdRemoved)
                {
                    this.OriginTelecomNumberId = default(string);
                }
            }
            else
            {
                this.OriginTelecomNumberId = e.OriginTelecomNumberId;
            }

            if (e.DestinationContactMechId == null)
            {
                if (e.IsPropertyDestinationContactMechIdRemoved)
                {
                    this.DestinationContactMechId = default(string);
                }
            }
            else
            {
                this.DestinationContactMechId = e.DestinationContactMechId;
            }

            if (e.DestinationTelecomNumberId == null)
            {
                if (e.IsPropertyDestinationTelecomNumberIdRemoved)
                {
                    this.DestinationTelecomNumberId = default(string);
                }
            }
            else
            {
                this.DestinationTelecomNumberId = e.DestinationTelecomNumberId;
            }

            if (e.PartyIdTo == null)
            {
                if (e.IsPropertyPartyIdToRemoved)
                {
                    this.PartyIdTo = default(string);
                }
            }
            else
            {
                this.PartyIdTo = e.PartyIdTo;
            }

            if (e.PartyIdFrom == null)
            {
                if (e.IsPropertyPartyIdFromRemoved)
                {
                    this.PartyIdFrom = default(string);
                }
            }
            else
            {
                this.PartyIdFrom = e.PartyIdFrom;
            }

            if (e.AdditionalShippingCharge == null)
            {
                if (e.IsPropertyAdditionalShippingChargeRemoved)
                {
                    this.AdditionalShippingCharge = default(decimal?);
                }
            }
            else
            {
                this.AdditionalShippingCharge = e.AdditionalShippingCharge;
            }

            if (e.AddtlShippingChargeDesc == null)
            {
                if (e.IsPropertyAddtlShippingChargeDescRemoved)
                {
                    this.AddtlShippingChargeDesc = default(string);
                }
            }
            else
            {
                this.AddtlShippingChargeDesc = e.AddtlShippingChargeDesc;
            }

            if (e.Active == null)
            {
                if (e.IsPropertyActiveRemoved)
                {
                    this.Active = default(bool);
                }
            }
            else
            {
                this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);
            }


            this.UpdatedBy = e.CreatedBy;
            this.UpdatedAt = e.CreatedAt;


            foreach (IShipmentImageEvent innerEvent in e.ShipmentImageEvents)
            {
                IShipmentImageState innerState = this.ShipmentImages.Get(innerEvent.GlobalId.SequenceId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IShipmentImageStateRemoved;
                if (removed != null)
                {
                    this.ShipmentImages.Remove(innerState);
                }
            }

            foreach (IShipmentItemEvent innerEvent in e.ShipmentItemEvents)
            {
                IShipmentItemState innerState = this.ShipmentItems.Get(innerEvent.GlobalId.ShipmentItemSeqId);

                innerState.Mutate(innerEvent);
            }

            foreach (IShipmentReceiptEvent innerEvent in e.ShipmentReceiptEvents)
            {
                IShipmentReceiptState innerState = this.ShipmentReceipts.Get(innerEvent.GlobalId.ReceiptSeqId);

                innerState.Mutate(innerEvent);
            }

            foreach (IItemIssuanceEvent innerEvent in e.ItemIssuanceEvents)
            {
                IItemIssuanceState innerState = this.ItemIssuances.Get(innerEvent.GlobalId.ItemIssuanceSeqId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IItemIssuanceStateRemoved;
                if (removed != null)
                {
                    this.ItemIssuances.Remove(innerState);
                }
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
0
        private ICreateOrMergePatchOrRemoveShipmentReceipt CreateOrUpdateShipmentReceipt(ShipmentCommands.ReceiveItem c, IShipmentState shipment, IShipmentItemState shipmentItem)
        {
            ICreateOrMergePatchOrRemoveShipmentReceipt updateReceipt = null;
            var receiptSeqId = c.ShipmentItemSeqId;
            var receipt      = shipment.ShipmentReceipts.Get(receiptSeqId, false, true);

            if (receipt == null)
            {
                updateReceipt = new CreateShipmentReceipt();
            }
            else
            {
                updateReceipt = new MergePatchShipmentReceipt();
            }

            var prdState = GetProductState(shipmentItem.ProductId);

            string attrSetInstId = AttributeSetInstanceUtils.CreateAttributeSetInstance(AttributeSetService, AttributeSetInstanceApplicationService,
                                                                                        prdState.AttributeSetId, c.AttributeSetInstance);

            if (_log.IsDebugEnabled)
            {
                _log.Debug("Create attribute set instance, id: " + attrSetInstId);
            }

            updateReceipt.AttributeSetInstanceId = attrSetInstId;

            updateReceipt.ReceiptSeqId      = receiptSeqId;
            updateReceipt.ShipmentItemSeqId = shipmentItem.ShipmentItemSeqId;
            updateReceipt.ProductId         = shipmentItem.ProductId;
            updateReceipt.AcceptedQuantity  = c.AcceptedQuantity;
            updateReceipt.RejectedQuantity  = c.RejectedQuantity;
            updateReceipt.DamagedQuantity   = c.DamagedQuantity;
            updateReceipt.DamageStatusIds   = c.DamageStatusIds;
            updateReceipt.DamageReasonId    = c.DamageReasonId;
            updateReceipt.ReceivedBy        = c.RequesterId;
            return(updateReceipt);
        }
Exemplo n.º 8
0
 public ShipmentItemStateDtoWrapper(IShipmentItemState state)
 {
     this._state = state;
 }
Exemplo n.º 9
0
 public ShipmentItemStateDtoWrapper()
 {
     this._state = new ShipmentItemState();
 }
Exemplo n.º 10
0
        public static TMergePatchShipmentItem ToMergePatchShipmentItem <TMergePatchShipmentItem>(this IShipmentItemState state)
            where TMergePatchShipmentItem : IMergePatchShipmentItem, new()
        {
            var cmd = new TMergePatchShipmentItem();

            cmd.ShipmentItemSeqId      = state.ShipmentItemSeqId;
            cmd.ProductId              = state.ProductId;
            cmd.AttributeSetInstanceId = state.AttributeSetInstanceId;
            cmd.Quantity = state.Quantity;
            cmd.ShipmentContentDescription = state.ShipmentContentDescription;
            cmd.Active     = ((IShipmentItemStateProperties)state).Active;
            cmd.ShipmentId = state.ShipmentId;

            if (state.ProductId == null)
            {
                cmd.IsPropertyProductIdRemoved = true;
            }
            if (state.AttributeSetInstanceId == null)
            {
                cmd.IsPropertyAttributeSetInstanceIdRemoved = true;
            }
            if (state.Quantity == null)
            {
                cmd.IsPropertyQuantityRemoved = true;
            }
            if (state.ShipmentContentDescription == null)
            {
                cmd.IsPropertyShipmentContentDescriptionRemoved = true;
            }
            return(cmd);
        }
Exemplo n.º 11
0
        public static IShipmentItemCommand ToCreateOrMergePatchShipmentItem <TCreateShipmentItem, TMergePatchShipmentItem>(this IShipmentItemState state)
            where TCreateShipmentItem : ICreateShipmentItem, new()
            where TMergePatchShipmentItem : IMergePatchShipmentItem, new()
        {
            bool bUnsaved = ((IShipmentItemState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateShipmentItem <TCreateShipmentItem>());
            }
            else
            {
                return(state.ToMergePatchShipmentItem <TMergePatchShipmentItem>());
            }
        }
Exemplo n.º 12
0
 public virtual void Remove(IShipmentItemState state)
 {
     this._removedShipmentItemStates.Add(state.GlobalId, state);
 }
Exemplo n.º 13
0
 public virtual void AddToSave(IShipmentItemState state)
 {
     this._loadedShipmentItemStates[state.GlobalId] = state;
 }
Exemplo n.º 14
0
 public void AddToSave(IShipmentItemState state)
 {
     throw new NotSupportedException();
 }