Exemple #1
0
        public static void TestModifyMenuItem()
        {
            MenuItem menuItem = new MenuItem(id: 2, name: "Burger", price: 129.00f, active: true, dateOfLaunch: DateUtility.ConvertToDate("2017/12/23"), category: "Main Course", freeDelivery: false);
            MenuItemDaoCollection menuItemDao = new MenuItemDaoCollection();

            menuItemDao.ModifyMenuItem(menuItem);
        }
Exemple #2
0
        public void AddCartItem(long userId, long menuItemId)
        {
            MenuItemDaoCollection menuDao = new MenuItemDaoCollection();

            // Get menuItem which you selected via menuItemId
            MenuItem menuItem = menuDao.GetMenuItem(menuItemId);

            // User exist ? Add products : Create User
            if (_userCarts.ContainsKey(userId))
            {
                _userCarts[userId].MenuItemList.Add(menuItem);
            }
            else
            {
                // Create new cart to save your items
                Cart newCart = new Cart();

                // Create List of menu items which you want to save in cart
                List <MenuItem> menuItems = new List <MenuItem>();
                menuItems.Add(menuItem);

                // Add list to Cart
                newCart.MenuItemList = menuItems;

                // Add data to cart dictionary via userId
                _userCarts.Add(userId, newCart);
            }
        }
Exemple #3
0
        public static void TestGetMenuItem()
        {
            Console.Write("Enter product ID to check:");
            long productID = long.Parse(Console.ReadLine());
            MenuItemDaoCollection menuItemDao = new MenuItemDaoCollection();

            menuItemDao.GetMenuItem(productID);
        }
Exemple #4
0
        public static void TestGetMenuItemListCustomer()
        {
            MenuItemDaoCollection menuItemDao = new MenuItemDaoCollection();

            Console.WriteLine("Customer Menu Item List \n Id  Name  Price  Active  Date of Launch  Category  Free Delivery  Action\n");
            menuItemDao.GetMenuItemListCustomer().ForEach(item => Console.WriteLine($"{item.Id} {item.Name} {item.Price} {(item.Active ? "Yes" : "No")} {item.DateOfLaunch} {item.Category} {(item.FreeDelivery ? "Yes" : "No")}"));
            Console.WriteLine();
        }
Exemple #5
0
        void TestModifyMenuItem()
        {
            menuItemDao           x = new menuItemDao();
            MenuItemDaoCollection y = new MenuItemDaoCollection(x);

            MenuItemDao.ModifyMenuItem(menuItem);
            MenuItemDao.GetMenuItem(producId);
        }
Exemple #6
0
        public void AddCartItem(long userId, long menuItemId)
        {
            var menuItemDao = new MenuItemDaoCollection();
            var menuItem    = menuItemDao.GetMenuItem(menuItemId);

            if (userCart.ContainsKey(userId))
            {
                userCart[userId].MenuItemList.Add(menuItem);
            }
            else
            {
                var cart = new Cart();
                cart.MenuItemList.Add(menuItem);
                userCart[userId] = cart;
            }
        }
        public void AddCartItem(long userId, long menuItemId)
        {
            MenuItemDaoCollection menuItemDaoCollection = new MenuItemDaoCollection();
            MenuItem menuItem = menuItemDaoCollection.GetMenuItem(menuItemId);

            if (UserCarts.ContainsKey(userId))
            {
                userCarts[userId].MenuItemList.Add(menuItem);
            }
            else
            {
                Cart cart = new Cart();
                cart.MenuItemList = new List <MenuItem>();
                cart.MenuItemList.Add(menuItem);
                UserCarts.Add(userId, cart);
            }
        }
Exemple #8
0
        public static void TestGetMenuItemListAdmin()
        {
            MenuItemDaoCollection menuItemDao = new MenuItemDaoCollection();

            Console.WriteLine("Admin Menu Item List \n Id  Name  Price  Active  Date of Launch  Category  Free Delivery  Action\n");
            foreach (var item in menuItemDao.GetMenuItemListAdmin())
            {
                Console.Write(item.Id + "   ");
                Console.Write(item.Name + "   ");
                Console.Write(item.Price + "  ");
                Console.Write(item.Active ? "Yes   " : "No   ");
                Console.Write(item.DateOfLaunch + "   ");
                Console.Write(item.Category + "   ");
                Console.Write(item.FreeDelivery ? "   Yes" : "   No");
                Console.WriteLine();
            }
            Console.WriteLine();
        }
Exemple #9
0
        void TestGetMenuItemListAdmin()
        {
            MenuItemDao           menuItemDao = new MenuItemDao();
            MenuItemDaoCollection y           = new MenuItemDaoCollection(menuItemDao);

            MenuItemDao.GetMenuItemListAdmin();
            while (menuItemList != 0)
            {
                foreach (MenuItem item in MenuItemList)
                {
                    Console.WriteLine(item.Name);
                    Console.WriteLine(item.Id);
                    Console.WriteLine(item.price);
                    Console.WriteLine(item.dateOfLaunh);
                    Console.WriteLine(item.available);
                }
            }
        }
Exemple #10
0
        void AddCartItem(long userId, long menuItemId)
        {
            menuItemDao           x = new menuItemDao();
            MenuItemDaoCollection y = new MenuItemDaoCollection(x);

            menuItemDao.GetMenuItem(menuItemId);
            if (user != null)
            {
                menuItemList;
                b.Add the menuItem obtained in previous step into menuItemList
            }
            else
            {
                a.Create a new Cart instance with new List
                                   b.Add the menu item obtained in step one and add it to menuItemList created in previous step
                                   c.Put the userId and List of MenuItem into the userCart
            }
        }
Exemple #11
0
        public void AddCartItem(long userId, long menuItemId)
        {
            MenuItemDaoCollection menuItemDao = new MenuItemDaoCollection();
            MenuItem menuItem = menuItemDao.GetMenuItem(menuItemId);

            if (userCart.ContainsKey(userId))
            {
                userCart[userId].MenuItemList.Add(menuItem);
            }
            else
            {
                List <MenuItem> menuItemList = new List <MenuItem>()
                {
                    menuItem
                };
                userCart.Add(userId, new Cart(menuItemList, 0));
            }
        }
        public void AddCartItem(long userId, long menuItemId)
        {
            MenuItemDaoCollection MenuItemDao = new MenuItemDaoCollection();
            MenuItem item = MenuItemDao.GetMenuItem(menuItemId);

            if (userCarts.ContainsKey(userId))
            {
                userCarts[userId].MenuItemList.Add(item);
            }
            else
            {
                Cart cart = new Cart()
                {
                    MenuItemList = new List <MenuItem>(),
                    Total        = 0
                };
                cart.MenuItemList.Add(item);
                userCarts.Add(userId, cart);
            }
        }