Пример #1
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);
            }
        }
Пример #2
0
        public void TestModifyMenuItem()
        {
            var menuItem = new MenuItem(2, "Burger", 150.00f, true, new DateTime(2021, 01, 27), "Main Course", false);

            menuItemDao.ModifyMenuItem(item: menuItem);
            Console.WriteLine(menuItemDao.GetMenuItem(menuItemId: 2));
        }
Пример #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);
        }
Пример #4
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;
            }
        }
Пример #5
0
        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);
            }
        }
Пример #6
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);
            }
        }