Exemple #1
0
        // GET: HomeController/GetMenu
        public async Task <IActionResult> MenuItems()
        {
            var categoriesObj = await _catRepo.FindAll();

            var categoriesVm = _mapper.Map <List <CategoryVM> >(categoriesObj);

            var starterCategory = await _catRepo.FindByName("Starter");

            var MenuItemStarters = await _repo.GetMenuItemsByCategory(starterCategory.Id);

            var MenuItemStartersVm = _mapper.Map <List <MenuItemVM> >(MenuItemStarters);



            var mainCourseCategory = await _catRepo.FindByName("Main Course");

            var menuItemMainCourse = await _repo.GetMenuItemsByCategory(mainCourseCategory.Id);

            var MenuItemMainCourseVm = _mapper.Map <List <MenuItemVM> >(menuItemMainCourse);

            var dessertCategory = await _catRepo.FindByName("Dessert");

            var menuItemDesserts = await _repo.GetMenuItemsByCategory(dessertCategory.Id);

            var MenuItemDessertsVm = _mapper.Map <List <MenuItemVM> >(menuItemDesserts);

            var model = new CustomerMenuVM
            {
                Categories = categoriesVm,
                Starters   = MenuItemStartersVm,
                MainCourse = MenuItemMainCourseVm,
                Desserts   = MenuItemDessertsVm
            };

            return(View(model));
        }