Пример #1
0
        static void Main(string[] args)
        {
            InventoryController inventoryControl = new InventoryController();
            RecipeController    recipeControl    = new RecipeController();
            MenuController      menuControl      = new MenuController();
            SalesController     salesControl     = new SalesController();
            ConsoleKeyInfo      input            = new ConsoleKeyInfo();

            Console.WriteLine("Welcome to Restaurant Expense Manager!");
            while (input.KeyChar != '7')
            {
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1 - Add Ingredient");
                Console.WriteLine("2 - Add Menu");
                Console.WriteLine("3 - View Menu");
                Console.WriteLine("4 - Add Today's Sale");
                Console.WriteLine("5 - Check Today's Sale");
                Console.WriteLine("6 - Check Inventory");
                Console.WriteLine("7 - exit");
                input = Console.ReadKey();
                Console.Clear();
                switch (input.KeyChar)
                {
                case '1':
                    inventoryControl.AddInventorySequence();
                    break;

                case '2':
                    menuControl.AddMenuSequence(inventoryControl, recipeControl);
                    break;

                case '3':
                    menuControl.DisplayMenu(recipeControl);
                    break;

                case '4':
                    salesControl.AddSaleSequence(menuControl, inventoryControl, recipeControl);
                    break;

                case '5':
                    salesControl.DisplayTotalSales(menuControl);
                    break;

                case '6':
                    inventoryControl.DisplaytTotalInventory();
                    break;

                default:
                    Console.WriteLine("Select a number 1 ~ 7");
                    break;
                }
            }
        }
Пример #2
0
 public void DisplayMenu(RecipeController recControl)
 {
     foreach (var menu in Menus)
     {
         Console.WriteLine($"{menu.Name} - $ {menu.Price}");
         if (menu.NeedRecipe)
         {
             var recipeCost = recControl.Recipes.Where(m => m.Name == menu.Name).First().calRecipeCost();
             var costMsg    = recipeCost == -1 ? "no inventory avaliable to calculate the cost" : "$" + recipeCost.ToString();
             var r          = recControl.Recipes.Where(m => m.Name == menu.Name).First().Ingredients;
             Console.WriteLine("Cost : " + costMsg);
             foreach (var ingredient in r)
             {
                 Console.WriteLine($"{ingredient.Name} - {ingredient.Weight} oz");
             }
         }
     }
 }
Пример #3
0
        public void AddSaleSequence(MenuController menuControl, InventoryController invControl, RecipeController recControl)
        {
            Console.WriteLine("Which item was sold?");
            var soldItem = Console.ReadLine();

            Console.WriteLine("How many?");
            var qty = int.Parse(Console.ReadLine());

            try
            {
                for (int i = 0; i < qty; i++)
                {
                    AddSale(menuControl.Menus.Where(m => m.Name == soldItem).First());
                    foreach (var ingredient in recControl.Recipes.Where(r => r.Name == soldItem).First().Ingredients)
                    {
                        invControl.UseInventory(ingredient);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("That menu does not exist");
            }
        }