示例#1
0
        static void Main(string[] args)
        {
            var categoryService = InstanceFactory.GetInstance <ICategoryService>();
            var productService  = InstanceFactory.GetInstance <IProductService>();
            var couponService   = InstanceFactory.GetInstance <ICouponService>();
            var campaignService = InstanceFactory.GetInstance <ICampaignService>();

            #region veritabanini doldur
            //InsertCategoryAndProducts(categoryService, productService);

            //InsertCoupons(couponService);

            //InsertCampaign(campaignService, categoryService);
            #endregion

            if (categoryService.GetByName("Kitap") != null)
            {
                Cart myCart = new Cart();
                myCart.UserId = 1;
                //her case için shopping metodu yazılır
                //bazı örnek caseler için shopping3 tanımlı olduğu regiona gidin
                shopping5(myCart, productService, categoryService);
                Console.WriteLine("*** Ürünler Sepete Eklendi ***");

                CartManager cartManager = new CartManager();
                Order       order       = cartManager.SaveCart(myCart);
                cartManager.DiscountCalculator = new CampaignDiscountCalculator();
                cartManager.ApplyDiscount(order);
                cartManager.DiscountCalculator = new CouponDiscountCalculator();
                cartManager.ApplyDiscount(order);
                cartManager.DeliveryCostCalculator = new StandardDeliveryCostCalculator(2, 1, (decimal)2.99);
                cartManager.ApplyDeliveryCost(order);
                order.State = 2;// tahsilata hazır
                cartManager.SetOrderForPayment(order);
                Console.WriteLine("*** Sepet Kaydedildi ***");
                Console.WriteLine("*********************************************************************");
                Console.WriteLine("*** Sipariş Özeti ***");
                Console.WriteLine(JsonConvert.SerializeObject(cartManager.GetOrderSummary(order)));
                Console.WriteLine("*** Sipariş Detay ***");
                Console.WriteLine(JsonConvert.SerializeObject(cartManager.GetOrderDetailSummary(order)));
            }
            else
            {
                Console.WriteLine("!!! Önce Database'i doldur.Region veritabanini dolduru aç !!!");
            }

            Console.ReadLine();
        }