예제 #1
0
 public MenuController(CofeeDbContext cofeeDbContext)
 {
     _cofeeDbContext = cofeeDbContext;
 }
예제 #2
0
        private void CoffeeSelection(int id)
        {
            bool t           = false;
            var  dbContext   = new CofeeDbContext();
            bool selectionOK = false;

            while (!selectionOK)
            {
                using (dbContext)
                {
                    switch (id)
                    {
                    case 1:
                        var cofename = dbContext.Coffees.Where(x => x.Id == 1);
                        foreach (var item in cofename)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                    DisplayCoffeesSelection();
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 2:
                        var cofename2 = dbContext.Coffees.Where(x => x.Id == 2);
                        foreach (var item in cofename2)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= { total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 3:
                        var cofename3 = dbContext.Coffees.Where(x => x.Id == 3);
                        foreach (var item in cofename3)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 4:
                        var cofename4 = dbContext.Coffees.Where(x => x.Id == 4);
                        foreach (var item in cofename4)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 5:
                        var cofename5 = dbContext.Coffees.Where(x => x.Id == 5);
                        foreach (var item in cofename5)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 6:
                        var cofename6 = dbContext.Coffees.Where(x => x.Id == 6);
                        foreach (var item in cofename6)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 7:
                        var cofename7 = dbContext.Coffees.Where(x => x.Id == 7);
                        foreach (var item in cofename7)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 8:
                        var cofename8 = dbContext.Coffees.Where(x => x.Id == 8);
                        foreach (var item in cofename8)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 9:
                        var cofename9 = dbContext.Coffees.Where(x => x.Id == 9);
                        foreach (var item in cofename9)
                        {
                            CostofCoffee = item.Price;
                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 10:
                        var cofename10 = dbContext.Coffees.Where(x => x.Id == 10);
                        foreach (var item in cofename10)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    case 11:
                        var cofename11 = dbContext.Coffees.Where(x => x.Id == 11);
                        foreach (var item in cofename11)
                        {
                            CostofCoffee = item.Price;

                            if (RunningTotal >= CostofCoffee)
                            {
                                if (total.coffee > item.Coffee && total.water > item.Water && total.sugar > item.Sugar)
                                {
                                    Console.WriteLine($"\nThank you for choosing {item.CoffeeName} product is ready");
                                    RunningTotal -= CostofCoffee;
                                    Console.WriteLine($"\nwater= {total.water -= item.Water} \nsugar= {total.sugar -= item.Sugar} \ncoffee= {total.coffee -= item.Coffee}");
                                    Console.WriteLine("\nYour change is {0}", RunningTotal);
                                    Console.WriteLine("\nPlease you action 0 for take change and 1 for continue order");
                                    Afteraction(t);
                                }
                                else
                                {
                                    Console.WriteLine("\nSorry  not enough ingredients in the store ");
                                }
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nyou don’t have enough money in your balance please add {0}", item.Price - RunningTotal);
                                Console.ForegroundColor = ConsoleColor.Gray;
                                DepositCoin(Convert.ToInt32(Console.ReadLine()));
                            }
                        }
                        selectionOK = true;
                        break;

                    default:
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\ninvalid Selection please select now");
                        Console.ForegroundColor = ConsoleColor.Gray;
                        DisplayCoffeesSelection();
                        break;
                    }
                }
            }
        }