Ejemplo n.º 1
0
        private void UpdateMenuItem()
        {
            ViewMenu();

            Console.WriteLine("Enter the ID of the item you would like to update");
            int oldId = Int16.Parse(Console.ReadLine());

            Console.Clear();
            MenuClass newItem = new MenuClass();

            newItem.ID = oldId;

            Console.WriteLine("Enter the name of the item.");
            newItem.Name = Console.ReadLine();

            Console.WriteLine("Enter the description of the item.");
            newItem.Description = Console.ReadLine();

            Console.WriteLine("Enter the ingredients for the item.");
            newItem.Ingredients = Console.ReadLine();

            Console.WriteLine("What is the price for this item?");
            newItem.Price = decimal.Parse(Console.ReadLine());

            bool wasUpdated = _menuRepo.UpdateMenuItem(oldId, newItem);

            if (wasUpdated)
            {
                Console.WriteLine("Item was succesfully updated.");
            }
            else
            {
                Console.WriteLine("Item could not be updated.");
            }
        }
Ejemplo n.º 2
0
        private void SeedMenuList()
        {
            MenuClass cheeseburger = new MenuClass(1, "Big Cheesy", "Two 80/20 100% USDA Beef between two perfectly toasted buns.\n", "Hamburger, Cheese, Lettuce, Tomato, Mayo, Onion.", 4.99m);
            MenuClass hotDog       = new MenuClass(2, "Hot Dog", "Hot dog between a toasted bun.\n", "Hot Dog, Mustard, Ketchup, Bun.", 1.50m);
            MenuClass steak        = new MenuClass(3, "Ribeye", "100% USDA Ribeye Steak.\n", "Steak, fried onions, herb butter", 14.99m);

            _menuRepo.AddToMenu(cheeseburger);
            _menuRepo.AddToMenu(hotDog);
            _menuRepo.AddToMenu(steak);
        }
Ejemplo n.º 3
0
        //Update
        public bool UpdateMenuItem(int item, MenuClass newItem)
        {
            //Find the item
            MenuClass oldItem = GetItemByID(item);

            //Update item
            if (oldItem != null)
            {
                oldItem.ID          = newItem.ID;
                oldItem.Name        = newItem.Name;
                oldItem.Description = newItem.Description;
                oldItem.Ingredients = newItem.Ingredients;
                oldItem.Price       = newItem.Price;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        private void AddNewItem()
        {
            Console.Clear();
            MenuClass item = new MenuClass();

            Console.WriteLine("Enter ID number.");
            item.ID = Int16.Parse(Console.ReadLine());

            Console.WriteLine("Enter item's name.");
            item.Name = Console.ReadLine();

            Console.WriteLine("Enter the description.");
            item.Description = Console.ReadLine();

            Console.WriteLine("What ingredients does this item have?");
            item.Ingredients = Console.ReadLine();

            Console.WriteLine("What is the price of this item?");
            item.Price = Decimal.Parse(Console.ReadLine());

            _menuRepo.AddToMenu(item);
        }
Ejemplo n.º 5
0
        private void ViewItemByID()
        {
            Console.Clear();

            Console.WriteLine("Enter the ID of item you would like to see.");
            int id = Int16.Parse(Console.ReadLine());

            MenuClass item = _menuRepo.GetItemByID(id);

            if (item != null)
            {
                Console.WriteLine($"ID: {item.ID}\n" +
                                  $"Name: {item.Name}\n" +
                                  $"Description: {item.Description}\n" +
                                  $"Ingredients: {item.Ingredients}\n" +
                                  $"Price: {item.Price}");
            }
            else
            {
                Console.WriteLine("No item by that ID");
            }
        }
Ejemplo n.º 6
0
        //Delete
        public bool RemoveMenuItem(int id)
        {
            MenuClass item = GetItemByID(id);

            if (item == null)
            {
                return(false);
            }

            int initialCount = _menu.Count;

            _menu.Remove(item);

            if (initialCount > _menu.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
 //Create
 public void AddToMenu(MenuClass item)
 {
     _menu.Add(item);
 }