Exemplo n.º 1
0
        public async Task <IEnumerable <MenuAC> > MenusOfRestaurant(int id)
        {
            var menusOfRestaurant = await _context
                                    .MenuCategory
                                    .Include(m => m.Restaurant)
                                    .Where(m => m.RestaurantId == id && m.IsDeleted == false)
                                    .ToListAsync();

            foreach (var menu in menusOfRestaurant)
            {
                MenuAC menuAC = new MenuAC();
                menuAC.MenuCategoryName = menu.MenuCategoryName;
                menuAC.Id             = menu.Id;
                menuAC.TotalDishes    = this.CountTotalDishes(menu.Id);
                menuAC.RestaurantId   = menu.RestaurantId;
                menuAC.RestaurantName = menu.Restaurant.Name;
                menuAC.PhoneNumber    = menu.Restaurant.PhoneNumber;
                menuAC.EmailId        = menu.Restaurant.EmailId;
                var Dishes = await _context
                             .Dish
                             .Where(d => d.MenuCategoryId == menu.Id && d.IsDeleted == false)
                             .ToListAsync();

                List <DishAC> DishesOfMenu = new List <DishAC>();

                foreach (var dish in Dishes)
                {
                    DishAC dishAC = new DishAC();
                    dishAC.Id             = dish.Id;
                    dishAC.DishName       = dish.DishName;
                    dishAC.Price          = dish.Price;
                    dishAC.MenuCategoryId = dish.MenuCategoryId;
                    DishesOfMenu.Add(dishAC);
                }
                menuAC.Dishes = DishesOfMenu;
                MenuList.Add(menuAC);
            }

            return(MenuList);
        }
Exemplo n.º 2
0
        public async Task <MenuAC> GetMenu(int menuId)
        {
            var category = await _context.MenuCategory.FindAsync(menuId);

            var dishes = await _context.Dish
                         .Where(d => d.MenuCategoryId == menuId && d.IsDeleted == false)
                         .ToListAsync();

            MenuAC menuAC = new MenuAC();

            menuAC.MenuCategoryName = category.MenuCategoryName;
            List <DishAC> dishACs = new List <DishAC>();

            foreach (var d in dishes)
            {
                DishAC dish = new DishAC();
                dish.DishName = d.DishName;
                dish.Price    = d.Price;
                dishACs.Add(dish);
            }
            menuAC.Dishes = dishACs;
            return(menuAC);
        }