public static void Main() { string choice; Console.WriteLine("What would you like to order? 1-Grocery Items, 2- Bakery Products"); choice = Console.ReadLine(); if (choice == "1") { GroceryItems grocery = new GroceryItems(); grocery.Ord_grocery(); } else { if (choice == "2") { BakeryProducts bakery = new BakeryProducts(); bakery.Ord_bakery(); } else { Console.WriteLine("Enter either 1 or 2"); } } Console.ReadLine(); }
public void ReturnToWarehouse(object sender, BakeryEventArgs args) { var bakeryProduct = _context.BakeryProducts.FirstOrDefault(bp => bp.Name == args.OrderedBakeryProduct.Name); if (bakeryProduct == null) { var newBakeryProduct = args.OrderedBakeryProduct.ToModel(); _context.BakeryProducts.Add(newBakeryProduct); } else { bakeryProduct.Quantity += args.OrderedBakeryProduct.Quantity; } _context.SaveChanges(); var bakeryProductView = BakeryProducts.FirstOrDefault(bp => bp.Name == args.OrderedBakeryProduct.Name); if (bakeryProductView == null) { BakeryProducts.Add(args.OrderedBakeryProduct); } else { bakeryProductView.Quantity += args.OrderedBakeryProduct.Quantity; } var orderedItem = OrderedProducts.FirstOrDefault(bp => bp.Name == args.OrderedBakeryProduct.Name); OrderedProducts.Remove(orderedItem); RaisePropertyChanged("BakeryProducts"); RaisePropertyChanged("OrderedProducts"); LoadProducts(); }
private async void SearchHandler(object param) { BakeryProducts.Clear(); var textBox = param as TextBox; var searchQuery = textBox.Text; var bakeryProducts = await _context.BakeryProducts .Where(p => p.Name.Contains(searchQuery)) .ToListAsync(); foreach (var bakeryProduct in bakeryProducts) { BakeryProducts.Add(bakeryProduct.ToDomain()); } RaisePropertyChanged("BakeryProducts"); }
static void Main(string[] args) { CostomerName name = new CostomerName(); GroceryItems item = new GroceryItems(); BakeryProducts bakery = new BakeryProducts(); int n = 0; name.ReadName(); do { Console.Write("Orders: \n" + "1. Grocery Items \n" + "2. Bakery Products \n" + "Choose: "); n = Convert.ToInt32(Console.ReadLine()); while (n < 0 || n > 2) { Console.Write("Order: \n" + "1. Grocery Items \n" + "2. Bakery Products \n" + "Choose: "); n = Convert.ToInt32(Console.ReadLine()); } switch (n) { case 1: item.Items(); break; case 2: bakery.Bakery(); break; } }while (n != 0); Console.WriteLine("------------- \n" + name.getName()); item.ReadItems(); bakery.ReadBakery(); }