示例#1
0
        public void Discount_CanReadDiscountDetailListFromXml()
        {
            var details = new List <DiscountDetail>();
            var d1      = new DiscountDetail {
                Description = "Hello, World", Amount = -1.56m
            };

            details.Add(d1);
            var d2 = new DiscountDetail {
                Description = "Cool Item Two", Amount = -1.10m
            };

            details.Add(d2);
            var xml = DiscountDetail.ListToXml(details);

            List <DiscountDetail> actual;

            actual = DiscountDetail.ListFromXml(xml);

            Assert.AreEqual(details.Count, actual.Count, "Count of items didn't match");
            for (var i = 0; i < details.Count; i++)
            {
                Assert.AreEqual(details[i].Amount, actual[i].Amount, "Amount Didn't Match");
                Assert.AreEqual(details[i].Description, actual[i].Description, "Description Didn't Match");
                Assert.AreEqual(details[i].Id, actual[i].Id, "Id Didn't Match");
            }
        }
示例#2
0
        public void Discount_CanReadDiscountDetailListFromXmlWhenNoElementsInside()
        {
            var xml = "<DiscountDetails />";

            List <DiscountDetail> actual;

            actual = DiscountDetail.ListFromXml(xml);

            Assert.IsNotNull(actual, "List should not be null after reading.");
            Assert.AreEqual(actual.Count, 0, "Actual count should be zero");
        }
示例#3
0
        public void Discount_CanReadDiscountDetailListFromXmlWhenEmpty()
        {
            var xml = string.Empty;

            List <DiscountDetail> actual;

            actual = DiscountDetail.ListFromXml(xml);

            Assert.IsNotNull(actual, "List should not be null after reading.");
            Assert.AreEqual(actual.Count, 0, "Actual count should be zero");
        }
        /// <summary>
        ///     Creates a copy of the line item with the same ID as the original.
        /// </summary>
        /// <param name="copyId">If true, the line item ID will be copied.</param>
        /// <returns>LineItem</returns>
        public LineItem Clone(bool copyId)
        {
            var result = new LineItem();

            result.LastUpdatedUtc          = LastUpdatedUtc;
            result.BasePricePerItem        = BasePricePerItem;
            result.DiscountDetails         = DiscountDetail.ListFromXml(DiscountDetail.ListToXml(DiscountDetails));
            result.OrderBvin               = OrderBvin;
            result.ProductId               = ProductId;
            result.VariantId               = VariantId;
            result.ProductName             = ProductName;
            result.ProductSku              = ProductSku;
            result.ProductShortDescription = ProductShortDescription;
            result.Quantity              = Quantity;
            result.QuantityReturned      = QuantityReturned;
            result.QuantityShipped       = QuantityShipped;
            result.ShippingPortion       = ShippingPortion;
            result.StatusCode            = StatusCode;
            result.StatusName            = StatusName;
            result.TaxRate               = TaxRate;
            result.TaxPortion            = TaxPortion;
            result.SelectionData         = SelectionData;
            result.IsNonShipping         = IsNonShipping;
            result.ShippingCharge        = ShippingCharge;
            result.TaxSchedule           = TaxSchedule;
            result.ProductShippingHeight = ProductShippingHeight;
            result.ProductShippingLength = ProductShippingLength;
            result.ProductShippingWeight = ProductShippingWeight;
            result.ProductShippingWidth  = ProductShippingWidth;
            result.ShipSeparately        = ShipSeparately;

            foreach (var y in CustomProperties)
            {
                result.CustomProperties.Add(y.Clone());
            }

            if (copyId)
            {
                result.Id = Id;
            }

            return(result);
        }
示例#5
0
        public LineItem Clone(bool copyId)
        {
            LineItem result = new LineItem();

            result.LastUpdatedUtc          = this.LastUpdatedUtc;
            result.BasePricePerItem        = this.BasePricePerItem;
            result.DiscountDetails         = DiscountDetail.ListFromXml(DiscountDetail.ListToXml(this.DiscountDetails));
            result.OrderBvin               = this.OrderBvin;
            result.ProductId               = this.ProductId;
            result.VariantId               = this.VariantId;
            result.ProductName             = this.ProductName;
            result.ProductSku              = this.ProductSku;
            result.ProductShortDescription = this.ProductShortDescription;
            result.Quantity         = this.Quantity;
            result.QuantityReturned = this.QuantityReturned;
            result.QuantityShipped  = this.QuantityShipped;
            result.ShippingPortion  = this.ShippingPortion;
            result.StatusCode       = this.StatusCode;
            result.StatusName       = this.StatusName;
            result.TaxPortion       = this.TaxPortion;
            foreach (var x in this.SelectionData)
            {
                result.SelectionData.Add(x);
            }
            result.ShippingSchedule      = this.ShippingSchedule;
            result.TaxSchedule           = this.TaxSchedule;
            result.ProductShippingHeight = this.ProductShippingHeight;
            result.ProductShippingLength = this.ProductShippingLength;
            result.ProductShippingWeight = this.ProductShippingWeight;
            result.ProductShippingWidth  = this.ProductShippingWidth;
            foreach (var y in this.CustomProperties)
            {
                result.CustomProperties.Add(y.Clone());
            }

            if (copyId)
            {
                result.Id = this.Id;
            }

            return(result);
        }
 protected override void CopyDataToModel(hcc_Order data, Order model)
 {
     model.AffiliateID = data.AffiliateId;
     model.BillingAddress.FromXmlString(data.BillingAddress);
     model.bvin             = DataTypeHelper.GuidToBvin(data.bvin);
     model.CustomProperties = CustomPropertyCollection.FromXml(data.CustomProperties);
     model.FraudScore       = data.FraudScore;
     model.TotalHandling    = data.HandlingTotal;
     model.Id                      = data.Id;
     model.Instructions            = data.Instructions;
     model.IsPlaced                = data.IsPlaced == 1;
     model.LastUpdatedUtc          = data.LastUpdated;
     model.OrderDiscountDetails    = DiscountDetail.ListFromXml(data.OrderDiscountDetails);
     model.OrderNumber             = data.OrderNumber;
     model.PaymentStatus           = (OrderPaymentStatus)data.PaymentStatus;
     model.ShippingDiscountDetails = DiscountDetail.ListFromXml(data.ShippingDiscountDetails);
     model.ShippingAddress.FromXmlString(data.ShippingAddress);
     model.ShippingMethodDisplayName   = data.ShippingMethodDisplayName;
     model.ShippingMethodId            = data.ShippingMethodId;
     model.ShippingProviderId          = data.ShippingProviderId;
     model.ShippingProviderServiceCode = data.ShippingProviderServiceCode;
     model.ShippingStatus = (OrderShippingStatus)data.ShippingStatus;
     model.TotalShippingBeforeDiscounts = data.ShippingTotal;
     model.TotalShippingAfterDiscounts  = data.AdjustedShippingTotal;
     model.StatusCode           = data.StatusCode;
     model.StatusName           = data.StatusName;
     model.StoreId              = data.StoreId;
     model.ItemsTax             = data.ItemsTax;
     model.ShippingTax          = data.ShippingTax;
     model.ShippingTaxRate      = data.ShippingTaxRate;
     model.TotalTax             = data.TaxTotal;
     model.ThirdPartyOrderId    = data.ThirdPartyOrderId;
     model.TimeOfOrderUtc       = data.TimeOfOrder;
     model.UserEmail            = data.UserEmail;
     model.UserID               = data.UserId;
     model.UserDeviceType       = (DeviceType)data.UserDeviceType;
     model.IsAbandonedEmailSent = data.IsAbandonedEmailSent;
     model.UsedCulture          = data.UsedCulture;
 }
示例#7
0
        protected override void CopyDataToModel(hcc_LineItem data, LineItem model)
        {
            model.Id = data.Id;
            model.IsUserSuppliedPrice  = data.IsUserSuppliedPrice;
            model.IsGiftCard           = data.IsGiftCard;
            model.BasePricePerItem     = data.BasePrice;
            model.AdjustedPricePerItem = data.AdjustedPrice;
            model.CustomPropertiesFromXml(data.CustomProperties);
            model.DiscountDetails         = DiscountDetail.ListFromXml(data.DiscountDetails);
            model.LastUpdatedUtc          = data.LastUpdated;
            model.LineTotal               = data.LineTotal;
            model.OrderBvin               = DataTypeHelper.GuidToBvin(data.OrderBvin);
            model.ProductId               = DataTypeHelper.GuidToBvin(data.ProductId);
            model.ProductName             = data.ProductName;
            model.ProductShippingHeight   = data.ProductShippingHeight;
            model.ProductShippingLength   = data.ProductShippingLength;
            model.ProductShippingWeight   = data.ProductShippingWeight;
            model.ProductShippingWidth    = data.ProductShippingWidth;
            model.ProductShortDescription = data.ProductShortDescription;
            model.ProductSku              = data.ProductSku;
            model.Quantity         = data.Quantity;
            model.QuantityReturned = data.QuantityReturned;
            model.QuantityShipped  = data.QuantityShipped;
            model.SelectionData.DeserializeFromXml(data.SelectionData);
            model.ShippingPortion = data.ShippingPortion;
            model.IsNonShipping   = data.IsNonShipping == 1 ? true : false;
            model.StatusCode      = data.StatusCode;
            model.StatusName      = data.StatusName;
            model.StoreId         = data.StoreId;
            model.TaxRate         = data.TaxRate;
            model.ShippingTaxRate = data.ShippingTaxRate;
            model.TaxPortion      = data.TaxPortion;
            model.TaxSchedule     = data.TaxScheduleId;
            model.VariantId       = data.VariantId;
            model.ShipFromAddress.FromXmlString(data.ShipFromAddress);
            model.ShipFromMode           = (ShippingMode)data.ShipFromMode;
            model.ShipFromNotificationId = data.ShipFromNotificationId;
            model.ExtraShipCharge        = data.ExtraShipCharge;
            model.ShippingCharge         = (ShippingChargeType)data.ShippingCharge;
            model.ShipSeparately         = data.ShipSeparately;
            model.IsBundle                      = data.IsBundle;
            model.QuantityReserved              = data.QuantityReserved;
            model.IsRecurring                   = data.IsRecurring;
            model.RecurringBilling.Interval     = data.RecurringInterval ?? 0;
            model.RecurringBilling.IntervalType = (RecurringIntervalType)(data.RecurringIntervalType ?? 0);
            model.RecurringBilling.IsCancelled  = data.IsRecurringCancelled;
            model.PromotionIds                  = data.PromotionIds;
            model.FreeQuantity                  = data.FreeQuantity;

            if (model.CustomPropertyGet(HCC_KEY, "ismarkedforfreeshipping") == true.ToString())
            {
                model.IsMarkedForFreeShipping = true;
            }
            else
            {
                model.IsMarkedForFreeShipping = false;
            }
            model.IsTaxExempt = model.CustomPropertyGetAsBool(HCC_KEY, "istaxexempt");

            // Free Shipping Method Ids
            var freeshippingids = model.CustomPropertyGet(HCC_KEY, "freeshippingmethodsids");

            if (freeshippingids.Trim().Length > 0)
            {
                var methods = freeshippingids.Split(',');
                foreach (var methodId in methods)
                {
                    //Always add method id as upper invariant to avoid issue on comparision
                    model.FreeShippingMethodIds.Add(methodId.ToUpperInvariant());
                }
            }
        }