Exemple #1
0
    public decimal CalculateDiscount(CartItemList cart)
    {
        DiscountDA discount = new DiscountDA();

        List <string>  cakeNames    = new List <string>();
        List <decimal> cakeDiscount = new List <decimal>();

        cakeNames    = discount.getDiscountCakeName();
        cakeDiscount = discount.getDiscountCakeAmount();

        decimal amountOfDiscount = 0;

        for (int x = 0; x < cart.Count; x++)
        {
            string selectedCakeName = cart.GetNameOfCake(x);
            int    counter          = 0;
            while (counter < cakeNames.Count)
            {
                if (selectedCakeName == cakeNames[counter])
                {
                    decimal discountAmount = cakeDiscount[counter];
                    amountOfDiscount += cart.DiscountAmountForSummary(discountAmount, x);
                    counter           = cakeNames.Count;
                }
                else
                {
                    counter++;
                }
            }
        }
        return(amountOfDiscount);
    }