Beispiel #1
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);
        }
        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);
        }
Beispiel #3
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 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);
        }
Beispiel #5
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 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.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();

            base.ToModel(order);

            Sum = order.Total;

            return(order);
        }