public virtual Shipment ToModel(Shipment shipment)
        {
            if (shipment == null)
            {
                throw new ArgumentNullException(nameof(shipment));
            }

            shipment.Id           = Id;
            shipment.CreatedBy    = CreatedBy;
            shipment.CreatedDate  = CreatedDate;
            shipment.ModifiedBy   = ModifiedBy;
            shipment.ModifiedDate = ModifiedDate;

            shipment.Fee                   = Fee;
            shipment.FeeWithTax            = FeeWithTax;
            shipment.FulfillmentCenterId   = FulfillmentCenterId;
            shipment.ShipmentMethodCode    = ShipmentMethodCode;
            shipment.Total                 = Total;
            shipment.TotalWithTax          = TotalWithTax;
            shipment.TaxTotal              = TaxTotal;
            shipment.Price                 = Price;
            shipment.PriceWithTax          = PriceWithTax;
            shipment.DiscountAmount        = DiscountAmount;
            shipment.DiscountAmountWithTax = DiscountAmountWithTax;
            shipment.TaxPercentRate        = TaxPercentRate;
            shipment.Currency              = Currency;
            shipment.WeightUnit            = WeightUnit;
            shipment.Weight                = WeightValue;
            shipment.Height                = DimensionHeight;
            shipment.Length                = DimensionLength;
            shipment.WeightUnit            = DimensionUnit;
            shipment.Weight                = DimensionWidth;
            shipment.TaxType               = TaxType;
            shipment.ShipmentMethodOption  = ShipmentMethodOption;
            //TODO
            //shipment.TaxIncluded = TaxIncluded;
            //shipment.MeasureUnit =

            if (!Addresses.IsNullOrEmpty())
            {
                shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            if (!Discounts.IsNullOrEmpty())
            {
                shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Items.IsNullOrEmpty())
            {
                shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();
            }

            if (!TaxDetails.IsNullOrEmpty())
            {
                shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            return(shipment);
        }
Пример #2
0
        public virtual Payment ToModel(Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            payment.InjectFrom(this);

            if (!TaxDetails.IsNullOrEmpty())
            {
                payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            if (!Discounts.IsNullOrEmpty())
            {
                payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            return(payment);
        }
        public virtual Shipment ToModel(Shipment shipment)
        {
            if (shipment == null)
            {
                throw new ArgumentNullException(nameof(shipment));
            }

            shipment.InjectFrom(this);
            // workaround for mis-spelling
            shipment.FulfillmentCenterId = FulfilmentCenterId;

            if (!Addresses.IsNullOrEmpty())
            {
                shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            if (!Discounts.IsNullOrEmpty())
            {
                shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Items.IsNullOrEmpty())
            {
                shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();
            }

            if (!TaxDetails.IsNullOrEmpty())
            {
                shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            return(shipment);
        }
Пример #4
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var shipment = operation as Shipment;

            if (shipment == null)
            {
                throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            shipment.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            shipment.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();
            shipment.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            shipment.Packages   = Packages.Select(x => x.ToModel(AbstractTypeFactory <ShipmentPackage> .TryCreateInstance())).ToList();
            shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            base.ToModel(shipment);

            operation.Sum = shipment.TotalWithTax;

            return(shipment);
        }
Пример #5
0
        public override object Clone()
        {
            var result = base.Clone() as Shipment;

            result.Price                 = Price?.Clone() as Money;
            result.PriceWithTax          = PriceWithTax?.Clone() as Money;
            result.DiscountAmount        = DiscountAmount?.Clone() as Money;
            result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money;
            result.Total                 = Total?.Clone() as Money;
            result.TotalWithTax          = TotalWithTax?.Clone() as Money;
            result.TaxTotal              = TaxTotal?.Clone() as Money;


            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }
            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }
            if (Items != null)
            {
                result.Items = new List <CartShipmentItem>(Items.Select(x => x.Clone() as CartShipmentItem));
            }
            if (ValidationErrors != null)
            {
                result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError));
            }

            return(result);
        }
Пример #6
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.Id           = Id;
            lineItem.CreatedDate  = CreatedDate;
            lineItem.CreatedBy    = CreatedBy;
            lineItem.ModifiedDate = ModifiedDate;
            lineItem.ModifiedBy   = ModifiedBy;
            lineItem.OuterId      = OuterId;

            lineItem.PriceId                 = PriceId;
            lineItem.CatalogId               = CatalogId;
            lineItem.CategoryId              = CategoryId;
            lineItem.Currency                = Currency;
            lineItem.ProductId               = ProductId;
            lineItem.Sku                     = Sku;
            lineItem.ProductType             = ProductType;
            lineItem.Name                    = Name;
            lineItem.ImageUrl                = ImageUrl;
            lineItem.ShippingMethodCode      = ShippingMethodCode;
            lineItem.FulfillmentLocationCode = FulfillmentLocationCode;

            lineItem.Price                 = Price;
            lineItem.PriceWithTax          = PriceWithTax;
            lineItem.DiscountAmount        = DiscountAmount;
            lineItem.DiscountAmountWithTax = DiscountAmountWithTax;
            lineItem.Quantity              = Quantity;
            lineItem.TaxTotal              = TaxTotal;
            lineItem.TaxPercentRate        = TaxPercentRate;
            lineItem.Weight                = Weight;
            lineItem.Height                = Height;
            lineItem.Width                 = Width;
            lineItem.MeasureUnit           = MeasureUnit;
            lineItem.WeightUnit            = WeightUnit;
            lineItem.Length                = Length;
            lineItem.TaxType               = TaxType;
            lineItem.IsCancelled           = IsCancelled;
            lineItem.CancelledDate         = CancelledDate;
            lineItem.CancelReason          = CancelReason;
            lineItem.Comment               = Comment;
            lineItem.IsGift                = IsGift;
            lineItem.Discounts             = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            lineItem.TaxDetails            = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            lineItem.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            return(lineItem);
        }
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var order = operation as CustomerOrder;

            if (order == null)
            {
                throw new ArgumentException(@"operation argument must be of type CustomerOrder", nameof(operation));
            }

            order.CustomerId           = CustomerId;
            order.CustomerName         = CustomerName;
            order.StoreId              = StoreId;
            order.StoreName            = StoreName;
            order.OrganizationId       = OrganizationId;
            order.OrganizationName     = OrganizationName;
            order.EmployeeId           = EmployeeId;
            order.EmployeeName         = EmployeeName;
            order.DiscountAmount       = DiscountAmount;
            order.Total                = Total;
            order.SubTotal             = SubTotal;
            order.SubTotalWithTax      = SubTotalWithTax;
            order.ShippingTotal        = ShippingTotal;
            order.ShippingTotalWithTax = ShippingTotalWithTax;
            order.PaymentTotal         = PaymentTotal;
            order.PaymentTotalWithTax  = PaymentTotalWithTax;
            order.FeeTotal             = HandlingTotal;
            order.FeeTotalWithTax      = HandlingTotalWithTax;
            order.DiscountTotal        = DiscountTotal;
            order.DiscountTotalWithTax = DiscountTotalWithTax;
            order.DiscountAmount       = DiscountAmount;
            order.TaxTotal             = TaxTotal;
            order.IsPrototype          = IsPrototype;
            order.SubscriptionNumber   = SubscriptionNumber;
            order.SubscriptionId       = SubscriptionId;
            order.LanguageCode         = LanguageCode;
            order.TaxPercentRate       = TaxPercentRate;

            order.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            order.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList();
            order.Addresses  = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            order.Shipments  = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).OfType <Shipment>().ToList();
            order.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            order.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            order.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            base.ToModel(order);

            Sum = order.Total;

            return(order);
        }
Пример #8
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var shipment = operation as Shipment;

            if (shipment == null)
            {
                throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            shipment.Id           = Id;
            shipment.CreatedDate  = CreatedDate;
            shipment.CreatedBy    = CreatedBy;
            shipment.ModifiedDate = ModifiedDate;
            shipment.ModifiedBy   = ModifiedBy;

            shipment.Price                 = Price;
            shipment.PriceWithTax          = PriceWithTax;
            shipment.DiscountAmount        = DiscountAmount;
            shipment.DiscountAmountWithTax = DiscountAmountWithTax;
            shipment.FulfillmentCenterId   = FulfillmentCenterId;
            shipment.FulfillmentCenterName = FulfillmentCenterName;
            shipment.OrganizationId        = OrganizationId;
            shipment.OrganizationName      = OrganizationName;
            shipment.EmployeeId            = EmployeeId;
            shipment.EmployeeName          = EmployeeName;
            shipment.ShipmentMethodCode    = ShipmentMethodCode;
            shipment.ShipmentMethodOption  = ShipmentMethodOption;
            shipment.Height                = Height;
            shipment.Length                = Length;
            shipment.Weight                = Weight;
            shipment.Height                = Height;
            shipment.Width                 = Width;
            shipment.MeasureUnit           = MeasureUnit;
            shipment.WeightUnit            = WeightUnit;
            shipment.Length                = Length;
            shipment.TaxType               = TaxType;
            shipment.TaxPercentRate        = TaxPercentRate;
            shipment.TaxTotal              = TaxTotal;
            shipment.Total                 = Total;
            shipment.TotalWithTax          = TotalWithTax;

            shipment.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            shipment.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();
            shipment.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            shipment.Packages   = Packages.Select(x => x.ToModel(AbstractTypeFactory <ShipmentPackage> .TryCreateInstance())).ToList();
            shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            base.ToModel(shipment);

            operation.Sum = shipment.TotalWithTax;

            return(shipment);
        }
        public virtual ShoppingCart ToModel(ShoppingCart cart)
        {
            if (cart == null)
            {
                throw new ArgumentNullException(nameof(cart));
            }

            cart.Id           = Id;
            cart.CreatedBy    = CreatedBy;
            cart.CreatedDate  = CreatedDate;
            cart.ModifiedBy   = ModifiedBy;
            cart.ModifiedDate = ModifiedDate;

            cart.StoreId              = StoreId;
            cart.Fee                  = Fee;
            cart.FeeWithTax           = FeeWithTax;
            cart.Status               = Status;
            cart.Currency             = Currency;
            cart.ValidationType       = ValidationType;
            cart.CustomerId           = CustomerId;
            cart.CustomerName         = CustomerName;
            cart.IsAnonymous          = IsAnonymous;
            cart.IsRecuring           = IsRecuring;
            cart.LanguageCode         = LanguageCode;
            cart.Comment              = Comment;
            cart.OrganizationId       = OrganizationId;
            cart.Total                = Total;
            cart.SubTotal             = SubTotal;
            cart.SubTotalWithTax      = SubTotalWithTax;
            cart.ShippingTotal        = ShippingTotal;
            cart.ShippingTotalWithTax = ShippingTotalWithTax;
            cart.PaymentTotal         = PaymentTotal;
            cart.PaymentTotalWithTax  = PaymentTotalWithTax;
            cart.HandlingTotal        = HandlingTotal;
            cart.HandlingTotalWithTax = HandlingTotalWithTax;
            cart.DiscountTotal        = DiscountTotal;
            cart.DiscountTotalWithTax = DiscountTotalWithTax;
            cart.DiscountAmount       = DiscountAmount;
            cart.TaxTotal             = TaxTotal;
            cart.TaxPercentRate       = TaxPercentRate;
            cart.Type                 = Type;
            cart.Name                 = Name;

            cart.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            cart.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList();
            cart.Addresses  = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            cart.Shipments  = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).ToList();
            cart.Payments   = Payments.Select(x => x.ToModel(AbstractTypeFactory <Payment> .TryCreateInstance())).ToList();
            cart.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            cart.Coupons    = Coupons.Select(x => x.Code).ToList();

            // Assigning single coupon to preserve backwards compatibility with previous versions of CartModule
            cart.Coupon = cart.Coupons.FirstOrDefault();

            return(cart);
        }
Пример #10
0
        public virtual Payment ToModel(Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            payment.Id           = Id;
            payment.OuterId      = OuterId;
            payment.CreatedBy    = CreatedBy;
            payment.CreatedDate  = CreatedDate;
            payment.ModifiedBy   = ModifiedBy;
            payment.ModifiedDate = ModifiedDate;

            payment.Amount             = Amount;
            payment.PaymentGatewayCode = PaymentGatewayCode;
            payment.Price                 = Price;
            payment.PriceWithTax          = PriceWithTax;
            payment.DiscountAmount        = DiscountAmount;
            payment.DiscountAmountWithTax = DiscountAmountWithTax;
            payment.TaxType               = TaxType;
            payment.TaxPercentRate        = TaxPercentRate;
            payment.TaxTotal              = TaxTotal;
            payment.Total                 = Total;
            payment.TotalWithTax          = TotalWithTax;
            //TODO
            //payment.Purpose = Purpose;
            payment.Currency = Currency;

            if (!TaxDetails.IsNullOrEmpty())
            {
                payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            if (!Discounts.IsNullOrEmpty())
            {
                payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            payment.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            return(payment);
        }
Пример #11
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as LineItem;

            result.Price             = Price?.Clone() as Price;
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
Пример #12
0
        public object Clone()
        {
            var result = MemberwiseClone() as Payment;

            result.BillingAddress    = BillingAddress?.Clone() as Address;
            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
Пример #13
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as Shipment;

            result.DeliveryAddress   = DeliveryAddress?.Clone() as Address;
            result.Items             = Items?.Select(x => x.Clone()).OfType <ShipmentItem>().ToList();
            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
Пример #14
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.InjectFrom(this);
            lineItem.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            return(lineItem);
        }
Пример #15
0
        public override object Clone()
        {
            var result = base.Clone() as PaymentIn;

            result.PaymentMethod        = PaymentMethod?.Clone() as PaymentMethod;
            result.BillingAddress       = BillingAddress?.Clone() as Address;
            result.ProcessPaymentResult = ProcessPaymentResult?.Clone() as ProcessPaymentRequestResult;
            result.Transactions         = Transactions?.Select(x => x.Clone()).OfType <PaymentGatewayTransaction>().ToList();
            result.Discounts            = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails           = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();

            return(result);
        }
Пример #16
0
        public override object Clone()
        {
            var result = base.Clone() as CustomerOrder;

            result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.Addresses  = Addresses?.Select(x => x.Clone()).OfType <Address>().ToList();
            result.InPayments = InPayments?.Select(x => x.Clone()).OfType <PaymentIn>().ToList();
            result.Items      = Items?.Select(x => x.Clone()).OfType <LineItem>().ToList();
            result.Shipments  = Shipments?.Select(x => x.Clone()).OfType <Shipment>().ToList();
            result.Discounts  = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();

            return(result);
        }
        public override object Clone()
        {
            var result = MemberwiseClone() as ProductPrice;

            result.Currency       = Currency?.Clone() as Currency;
            result.DiscountAmount = DiscountAmount?.Clone() as Money;
            result.ListPrice      = ListPrice?.Clone() as Money;
            result.SalePrice      = SalePrice?.Clone() as Money;
            result.TierPrices     = TierPrices?.Select(x => x.Clone() as TierPrice).ToList();
            result.Discounts      = Discounts?.Select(x => x.Clone() as Discount).ToList();

            return(result);
        }
Пример #18
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as ShoppingCart;

            result.Discounts         = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.Addresses         = Addresses?.Select(x => x.Clone()).OfType <Address>().ToList();
            result.Items             = Items?.Select(x => x.Clone()).OfType <LineItem>().ToList();
            result.Payments          = Payments?.Select(x => x.Clone()).OfType <Payment>().ToList();
            result.Shipments         = Shipments?.Select(x => x.Clone()).OfType <Shipment>().ToList();
            result.TaxDetails        = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();
            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();

            return(result);
        }
Пример #19
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var payment = operation as PaymentIn;

            if (payment == null)
            {
                throw new ArgumentException(@"operation argument must be of type PaymentIn", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            payment.Price                 = Price;
            payment.PriceWithTax          = PriceWithTax;
            payment.DiscountAmount        = DiscountAmount;
            payment.DiscountAmountWithTax = DiscountAmountWithTax;
            payment.TaxType               = TaxType;
            payment.TaxPercentRate        = TaxPercentRate;
            payment.TaxTotal              = TaxTotal;
            payment.Total                 = Total;
            payment.TotalWithTax          = TotalWithTax;

            payment.CustomerId       = CustomerId;
            payment.CustomerName     = CustomerName;
            payment.OrganizationId   = OrganizationId;
            payment.OrganizationName = OrganizationName;
            payment.GatewayCode      = GatewayCode;
            payment.Purpose          = Purpose;
            payment.OuterId          = OuterId;
            payment.Status           = Status;
            payment.AuthorizedDate   = AuthorizedDate;
            payment.CapturedDate     = CapturedDate;
            payment.VoidedDate       = VoidedDate;
            payment.IsCancelled      = IsCancelled;
            payment.CancelledDate    = CancelledDate;
            payment.CancelReason     = CancelReason;
            payment.Sum = Sum;

            payment.Transactions = Transactions.Select(x => x.ToModel(AbstractTypeFactory <PaymentGatewayTransaction> .TryCreateInstance())).ToList();
            payment.TaxDetails   = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            payment.Discounts    = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();

            base.ToModel(payment);

            payment.PaymentStatus = EnumUtility.SafeParse(Status, PaymentStatus.Custom);

            return(payment);
        }
Пример #20
0
        public virtual LineItem ToModel(LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            lineItem.Id           = Id;
            lineItem.CreatedDate  = CreatedDate;
            lineItem.CreatedBy    = CreatedBy;
            lineItem.ModifiedDate = ModifiedDate;
            lineItem.ModifiedBy   = ModifiedBy;

            lineItem.PriceId                 = PriceId;
            lineItem.CatalogId               = CatalogId;
            lineItem.CategoryId              = CategoryId;
            lineItem.Currency                = Currency;
            lineItem.ProductId               = ProductId;
            lineItem.Sku                     = Sku;
            lineItem.ProductType             = ProductType;
            lineItem.Name                    = Name;
            lineItem.ImageUrl                = ImageUrl;
            lineItem.ShippingMethodCode      = ShippingMethodCode;
            lineItem.FulfillmentLocationCode = FulfillmentLocationCode;

            lineItem.Price                 = Price;
            lineItem.PriceWithTax          = PriceWithTax;
            lineItem.DiscountAmount        = DiscountAmount;
            lineItem.DiscountAmountWithTax = DiscountAmountWithTax;
            lineItem.Quantity              = Quantity;
            lineItem.TaxTotal              = TaxTotal;
            lineItem.TaxPercentRate        = TaxPercentRate;
            lineItem.Weight                = Weight;
            lineItem.Height                = Height;
            lineItem.Width                 = Width;
            lineItem.MeasureUnit           = MeasureUnit;
            lineItem.WeightUnit            = WeightUnit;
            lineItem.Length                = Length;
            lineItem.TaxType               = TaxType;
            lineItem.IsCancelled           = IsCancelled;
            lineItem.CancelledDate         = CancelledDate;
            lineItem.CancelReason          = CancelReason;
            lineItem.Comment               = Comment;
            lineItem.IsGift                = IsGift;
            lineItem.Discounts             = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            lineItem.TaxDetails            = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            return(lineItem);
        }
Пример #21
0
        public override object Clone()
        {
            var result = base.Clone() as Shipment;

            result.DeliveryAddress = DeliveryAddress?.Clone() as Address;
            result.ShippingMethod  = ShippingMethod?.Clone() as ShippingMethod;
            result.CustomerOrder   = CustomerOrder?.Clone() as CustomerOrder;

            result.Items      = Items?.Select(x => x.Clone()).OfType <ShipmentItem>().ToList();
            result.Packages   = Packages?.Select(x => x.Clone()).OfType <ShipmentPackage>().ToList();
            result.InPayments = InPayments?.Select(x => x.Clone()).OfType <PaymentIn>().ToList();
            result.Discounts  = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList();
            result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList();

            return(result);
        }
        public virtual Payment ToModel(Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            payment.Id           = Id;
            payment.CreatedBy    = CreatedBy;
            payment.CreatedDate  = CreatedDate;
            payment.ModifiedBy   = ModifiedBy;
            payment.ModifiedDate = ModifiedDate;

            payment.Amount             = Amount;
            payment.PaymentGatewayCode = PaymentGatewayCode;
            payment.Price                 = Price;
            payment.PriceWithTax          = PriceWithTax;
            payment.DiscountAmount        = DiscountAmount;
            payment.DiscountAmountWithTax = DiscountAmountWithTax;
            payment.TaxType               = TaxType;
            payment.TaxPercentRate        = TaxPercentRate;
            payment.TaxTotal              = TaxTotal;
            payment.Total                 = Total;
            payment.TotalWithTax          = TotalWithTax;
            //TODO
            //payment.Purpose = Purpose;
            payment.OuterId  = OuterId;
            payment.Currency = Currency;

            if (!TaxDetails.IsNullOrEmpty())
            {
                payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            }

            if (!Discounts.IsNullOrEmpty())
            {
                payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            return(payment);
        }
Пример #23
0
        public virtual ShoppingCart ToModel(ShoppingCart cart)
        {
            if (cart == null)
            {
                throw new ArgumentNullException(nameof(cart));
            }

            cart.InjectFrom(this);

            cart.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            cart.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList();
            cart.Addresses  = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            cart.Shipments  = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).ToList();
            cart.Payments   = Payments.Select(x => x.ToModel(AbstractTypeFactory <Payment> .TryCreateInstance())).ToList();
            cart.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            return(cart);
        }
Пример #24
0
 public ProductEntity(Product Product, params object[] args) : base(Product)
 {
     foreach (object arg in args)
     {
         if (arg is Category Category)
         {
             CategoryEntity = new CategoryEntity(Category);
         }
         if (arg is Manufacturer Manufacturer)
         {
             ManufacturerEntity = new ManufacturerEntity(Manufacturer);
         }
         if (arg is ICollection <Discount> Discounts)
         {
             DiscountEntities = Discounts.Select(model => new DiscountEntity(model)).ToList();
         }
         if (arg is ICollection <Inventory> Inventories)
         {
             InventoryEntities = Inventories.Select(model => new InventoryEntity(model, model.WareHouse)).ToList();
         }
         if (arg is ICollection <IssueNoteLine> IssueNoteLines)
         {
             IssueNoteLineEntities = IssueNoteLines.Select(model => new IssueNoteLineEntity(model, model.IssueNote)).ToList();
         }
         if (arg is ICollection <Pack> Packs)
         {
             PackEntities = Packs.Select(model => new PackEntity(model)).ToList();
         }
         if (arg is ICollection <ProductPicture> ProductPictures)
         {
             ProductPictureEntities = ProductPictures.Select(model => new ProductPictureEntity(model)).ToList();
         }
         if (arg is ICollection <ProductValue> ProductValues)
         {
             ProductValueEntities = ProductValues.Select(model => new ProductValueEntity(model, model.Attribute, model.Language)).ToList();
         }
         if (arg is ICollection <ReceiptNoteLine> ReceiptNoteLines)
         {
             ReceiptNoteLineEntities = ReceiptNoteLines.Select(model => new ReceiptNoteLineEntity(model, model.ReceiptNote)).ToList();
         }
     }
 }
Пример #25
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as LineItem;

            if (DynamicProperties != null)
            {
                result.DynamicProperties = new List <DynamicObjectProperty>(DynamicProperties.Select(x => x.Clone() as DynamicObjectProperty));
            }

            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }

            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }

            return(result);
        }
Пример #26
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var payment = operation as PaymentIn;

            if (payment == null)
            {
                throw new ArgumentException(@"operation argument must be of type PaymentIn", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            payment.Transactions = Transactions.Select(x => x.ToModel(AbstractTypeFactory <PaymentGatewayTransaction> .TryCreateInstance())).ToList();
            payment.TaxDetails   = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            payment.Discounts    = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();

            base.ToModel(payment);

            payment.PaymentStatus = EnumUtility.SafeParse(Status, PaymentStatus.Custom);

            return(payment);
        }
Пример #27
0
        public override object Clone()
        {
            var result = base.Clone() as ShoppingCart;

            result.HandlingTotal        = HandlingTotal?.Clone() as Money;
            result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money;
            result.DiscountAmount       = DiscountAmount?.Clone() as Money;
            result.Total                = Total?.Clone() as Money;
            result.SubTotal             = SubTotal?.Clone() as Money;
            result.SubTotalWithTax      = SubTotalWithTax?.Clone() as Money;
            result.ShippingPrice        = ShippingPrice?.Clone() as Money;
            result.ShippingPriceWithTax = ShippingPriceWithTax?.Clone() as Money;
            result.ShippingTotal        = ShippingTotal?.Clone() as Money;
            result.ShippingTotalWithTax = ShippingTotalWithTax?.Clone() as Money;
            result.PaymentPrice         = PaymentPrice?.Clone() as Money;
            result.PaymentPriceWithTax  = PaymentPriceWithTax?.Clone() as Money;
            result.PaymentTotal         = PaymentTotal?.Clone() as Money;
            result.PaymentTotalWithTax  = PaymentTotalWithTax?.Clone() as Money;
            result.HandlingTotal        = HandlingTotal?.Clone() as Money;
            result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money;
            result.DiscountTotal        = DiscountTotal?.Clone() as Money;
            result.DiscountTotalWithTax = DiscountTotalWithTax?.Clone() as Money;
            result.TaxTotal             = TaxTotal?.Clone() as Money;

            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }
            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }
            if (DynamicProperties != null)
            {
                result.DynamicProperties = new List <DynamicProperty>(DynamicProperties.Select(x => x.Clone() as DynamicProperty));
            }
            if (ValidationErrors != null)
            {
                result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError));
            }
            if (Addresses != null)
            {
                result.Addresses = new List <Address>(Addresses.Select(x => x.Clone() as Address));
            }
            if (Items != null)
            {
                result.Items = new List <LineItem>(Items.Select(x => x.Clone() as LineItem));
            }
            if (Payments != null)
            {
                result.Payments = new List <Payment>(Payments.Select(x => x.Clone() as Payment));
            }
            if (Shipments != null)
            {
                result.Shipments = new List <Shipment>(Shipments.Select(x => x.Clone() as Shipment));
            }
            if (Coupons != null)
            {
                result.Coupons = new List <Coupon>(Coupons.Select(x => x.Clone() as Coupon));
            }
            if (AvailablePaymentMethods != null)
            {
                result.AvailablePaymentMethods = new List <PaymentMethod>(AvailablePaymentMethods.Select(x => x.Clone() as PaymentMethod));
            }

            return(result);
        }