Beispiel #1
0
        public Discount CalcTotalDiscount(string storeName)
        {
            double beginPrice = Product.BasePrice;

            if (Discount?.discountType == DiscountTypeEnum.Visible && Discount.CheckTime())
            {
                beginPrice = Discount.CalcDiscount(beginPrice);
            }
            CategoryDiscount categoryDiscount = null;

            foreach (string categoryName in Product.Categories)
            {
                categoryDiscount = StoreDL.Instance.GetCategoryDiscount(categoryName, storeName);
                if (categoryDiscount != null)
                {
                    beginPrice = categoryDiscount.CalcDiscount(beginPrice);
                }
            }

            if (categoryDiscount != null)
            {
                return(new Discount(DiscountTypeEnum.Visible, categoryDiscount.StartDate, categoryDiscount.EndDate, (1 - beginPrice / Product.BasePrice) * 100, true));
            }

            return(Discount);
        }
Beispiel #2
0
        public void CheckIfDiscountExistsAndCalcValue(string storename)
        {
            double beginPrice = Product.BasePrice;

            if (Discount?.discountType == DiscountTypeEnum.Visible && Discount.CheckTime())
            {
                Product.BasePrice = Discount.CalcDiscount(Product.BasePrice);
            }
            CategoryDiscount categoryDiscount = null;

            foreach (string categoryName in Product.Categories)
            {
                categoryDiscount = StoreDL.Instance.GetCategoryDiscount(categoryName, storename);
                if (categoryDiscount != null)
                {
                    Product.BasePrice = categoryDiscount.CalcDiscount(Product.BasePrice);
                }
            }
        }