Пример #1
0
        //Static method for returning data
        public static List<Menu> GetAllMenus()
        {
            // Set up table adapters

            MenuTableAdapter taMenu = new MenuTableAdapter();
            MenuItemTableAdapter taMenuItem = new MenuItemTableAdapter();

            // assign data table to results from table adapter

            var dtMenu = taMenu.GetData();
            List<Menu> allMenus = new List<Menu>();

            // iterate  through rows in the datatable and do stuff n things

            foreach (dsDinerMax3000.MenuRow menuRow in dtMenu.Rows) {

                Menu currentMenu = new Menu(); // new menu object instance
                currentMenu.name = menuRow.Name; // get the assign it the name from the dataset
                currentMenu._databaseId = menuRow.id;
                allMenus.Add(currentMenu); // add it to the list of menus

                // get all the menu items of each menu while in the Menu loop and add to a list

                var dtMenuItems = taMenuItem.GetMenuItemsByMenuId(menuRow.id);

                foreach (dsDinerMax3000.MenuItemRow menuItemRow in dtMenuItems.Rows) { // for every menu item in the data table dtMenuItems

                    currentMenu.AddMenuItem(menuItemRow.Name, menuItemRow.Description, menuItemRow.Price); // add the menu items to the current menu object, from the dataset

                }

            }

            return allMenus;
        }
Пример #2
0
 public static List<Menu> GetAllMenus()
 {
     MenuTableAdapter taMenu = new MenuTableAdapter();
     MenuItemTableAdapter taMenuItem = new MenuItemTableAdapter();
     var dtMenu = taMenu.GetData();
     List<Menu> allMenus = new List<Menu>();
     foreach (dsDinerMax3000.MenuRow menuRow in dtMenu.Rows)
     {
         Menu currentMenu = new Menu();
         currentMenu._databaseId = menuRow.Id;
         currentMenu.Name = menuRow.Name;
         allMenus.Add(currentMenu);
         var dtMenuItems = taMenuItem.GetMenuItemsByMenuId(menuRow.Id);
         foreach(dsDinerMax3000.MenuItemRow menuItemRow in dtMenuItems.Rows)
         {
             currentMenu.AddMenuItem(menuItemRow.Name, menuItemRow.Description, menuItemRow.Price);
         }
     }
     return allMenus;
 }
Пример #3
0
        public static List<Menu> GetAllMenus()
        {
            MenuTableAdapter taMenu = new MenuTableAdapter();
            MenuItemTableAdapter taMenuItem = new MenuItemTableAdapter();
            var rsMenu = taMenu.GetData();
            List<Menu> allMenus = new List<Menu>();

            foreach (dsDinermax3000.MenuRow menuRow in rsMenu.Rows)
            {
                Menu currentMenu = new Menu();
                currentMenu.name = menuRow.Name;
                currentMenu._dbID = menuRow.ID;

                var rsMenuItems = taMenuItem.GetMenuItemsByMenuId(menuRow.ID);
                foreach (dsDinermax3000.MenuItemRow menuItemRow in rsMenuItems.Rows)
                {
                    currentMenu.addToMenu(menuItemRow.Name, menuItemRow.Description, menuItemRow.Price);
                }
                allMenus.Add(currentMenu);
            }
            return allMenus;
        }