Esempio n. 1
0
        void AddRules(ref Shop shop)
        {
            List <Product> productsInDiscount = new List <Product>();

            productsInDiscount.Add(A);
            productsInDiscount.Add(B);
            PercentType    discount = new PercentType(10);
            List <Product> productsNotInDiscount = new List <Product>();

            shop.AddRule(new RuleBuyItAll(discount, productsInDiscount, productsNotInDiscount));

            List <Product> productsInDiscount2 = new List <Product>();

            productsInDiscount2.Add(D);
            productsInDiscount2.Add(E);
            PercentType discount2 = new PercentType(5);

            DiscountModuleForOnlineStore.ValueType discount4 = new DiscountModuleForOnlineStore.ValueType(10);
            shop.AddRule(new RuleBuyItAll(discount4, productsInDiscount2, productsNotInDiscount));

            List <Product> productsInDiscount3 = new List <Product>();

            productsInDiscount3.Add(E);
            productsInDiscount3.Add(F);
            productsInDiscount3.Add(G);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount3, productsNotInDiscount));

            List <Product> productsInDiscount4    = new List <Product>();
            List <Product> productsNotInDiscount2 = new List <Product>();

            productsInDiscount4.Add(A);
            productsInDiscount4.Add(K);
            productsNotInDiscount2.Add(A);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount4, productsNotInDiscount2));

            List <Product> productsInDiscount5    = new List <Product>();
            List <Product> productsNotInDiscount3 = new List <Product>();

            productsInDiscount5.Add(A);
            productsInDiscount5.Add(L);
            productsNotInDiscount3.Add(A);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount5, productsNotInDiscount3));

            List <Product> productsInDiscount6    = new List <Product>();
            List <Product> productsNotInDiscount4 = new List <Product>();

            productsInDiscount6.Add(A);
            productsInDiscount6.Add(M);
            productsNotInDiscount4.Add(A);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount6, productsNotInDiscount4));

            List <Product> productsNotInDiscount5 = new List <Product>();

            productsNotInDiscount5.Add(A);
            productsNotInDiscount5.Add(C);

            int amount = 3;

            shop.AddRule(new RuleBuyMoreThan(discount2, productsNotInDiscount5, amount));

            amount = 4;
            shop.AddRule(new RuleBuyMoreThan(discount, productsNotInDiscount5, amount));

            amount = 5;
            PercentType discount3 = new PercentType(20);

            shop.AddRule(new RuleBuyMoreThan(discount3, productsNotInDiscount5, amount));
        }