Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,name")] ShoppingMall shoppingMall)
        {
            if (id != shoppingMall.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shoppingMall);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShoppingMallExists(shoppingMall.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(shoppingMall));
        }
Ejemplo n.º 2
0
        private static void StrategyPattern(DayOfWeek dayOfWeek)
        {
            IDiscountStrategy discountStrategy;

            switch (dayOfWeek)
            {
            case DayOfWeek.Monday:
            {
                discountStrategy = new HighDiscountStrategy();
                break;
            }

            case DayOfWeek.Thursday:
            {
                discountStrategy = new LowDiscountStrategy();
                break;
            }

            default:
            {
                discountStrategy = new NoDiscountStrategy();
                break;
            }
            }


            var mall = new ShoppingMall(discountStrategy);

            mall.CustomerName = "Raquel";
            mall.BillAmount   = 400;

            var discount = (double)mall.GetFinalBill() / mall.BillAmount;

            Console.WriteLine($"The Customer {mall.CustomerName} is bought {mall.BillAmount}€ and got a discount of {100 - discount * 100}%");
        }
Ejemplo n.º 3
0
    public static void Main(string[] args)
    {
        Console.WriteLine("Test");
        ShoppingMall shopmall = new ShoppingMall(new SalePrice());

        Console.WriteLine(shopmall.ObjStrat.GetBillAmount(100).ToString());
    }
Ejemplo n.º 4
0
        public override void Update(Promotion promotion, ShoppingMall shoppingMall)
        {
            if (promotion == null || shoppingMall == null || promotion.ForVIPCustomer)
            {
                return;
            }

            Console.WriteLine(string.Format("Xin chao {0}, ban co 1 khuyen mai tu {1}: {2}", CustomerName, shoppingMall.Name, promotion.Content));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("id,name")] ShoppingMall shoppingMall)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shoppingMall);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shoppingMall));
        }
Ejemplo n.º 6
0
        public void Work()
        {
            var shoppingMall = new ShoppingMall();

            var incomeProductsObserver = new IncomeProductObserver();
            var saleProductsObserver   = new SellProductObserver();

            shoppingMall.AddSubscriber(incomeProductsObserver);
            shoppingMall.AddSubscriber(saleProductsObserver);

            shoppingMall.MakeSell();
            shoppingMall.IncomeNewProduct();
            shoppingMall.MakeSell();
            shoppingMall.DeleteSubscriber(saleProductsObserver);
            shoppingMall.MakeSell();
            shoppingMall.IncomeNewProduct();
        }
Ejemplo n.º 7
0
 public abstract void Update(Promotion promotion, ShoppingMall shoppingMall);