Ejemplo n.º 1
0
        public void TestGetMenuItemListAdmin()
        {
            var menuListAdmin = menuItemDao.GetMenuItemListAdmin();

            foreach (var item in menuListAdmin)
            {
                Console.WriteLine(item);
            }
        }
Ejemplo n.º 2
0
        public Cart GetAllCartItems(long userId)
        {
            var menuItemDaoSql = new MenuItemDaoSql();
            var menuItemList   = menuItemDaoSql.GetMenuItemListAdmin();
            var cart           = new Cart();

            using (var conn = new SqlConnection(Helper.ConnectionString))
            {
                string query = $"select * from carts";
                var    cmd   = new SqlCommand(query, conn);
                conn.Open();
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int itemId = (int)reader["item_id"];
                    cart.MenuItemList.Add(menuItemList[itemId - 1]);
                }
            }
            cart.Total = cart.MenuItemList.Sum(x => x.Price);

            return(cart);
        }