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)); }
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}%"); }
public static void Main(string[] args) { Console.WriteLine("Test"); ShoppingMall shopmall = new ShoppingMall(new SalePrice()); Console.WriteLine(shopmall.ObjStrat.GetBillAmount(100).ToString()); }
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)); }
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)); }
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(); }
public abstract void Update(Promotion promotion, ShoppingMall shoppingMall);