Ejemplo n.º 1
0
        public ActionResult Index(RestaurantIndexViewModel dropdown)
        {
            // Creer lijst
            List <Restaurant> allRes;

            // Bekijk of de dropdown lijst leeg is of vol
            if (dropdown.RestaurantModel.FoodType1 == null)
            {
                // Stop lijst met alle restaurants, is het geval als de user klikt op all Categories
                allRes = _restaurantRepo.RestaurantList();
            }
            else
            {
                // stopt een lijst met alle restaurants met de cuisine die gekozen is
                allRes = _restaurantRepo.ListRestaurantFromFoodType(dropdown.RestaurantModel.FoodType1);
            }
            // Creeer een filter weer als de user weer wil gaan fiteren
            List <String> allFoodTypes    = _restaurantRepo.GetAllFoodTypes();
            var           selectlistitems = allFoodTypes.Select(x => new SelectListItem()
            {
                Value = x, Text = x
            });

            if (allRes == null || allFoodTypes == null || selectlistitems == null)
            {
                return(RedirectToAction("PageNotFound", "Home"));
            }
            RestaurantIndexViewModel vm = new RestaurantIndexViewModel(allRes, selectlistitems);

            return(View(vm));
        }
        public IActionResult Index()
        {
            var model = new RestaurantIndexViewModel();

            model.Restaurants    = _restaurantData.GetAll();
            model.CurrentMessage = "Måndag";

            return(View(model));
        }
Ejemplo n.º 3
0
        //[AllowAnonymous]
        public IActionResult Index()
        {
            var model = new RestaurantIndexViewModel();

            model.Restaurants         = _restaurantData.GetAll();
            model.Hello               = _greeter.GetTime();
            model.SomeCountMessage    = _restaurantService.CountMessage();
            model.SomethingFromGoogle = _httpService.Get("http://www.google.com").Result.Substring(0, 100);
            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Index(RestaurantIndexViewModel restaurantIndexViewModel)
        {
            var restaurants = await this.restaurantsService.GetAllAsync();

            if (restaurantIndexViewModel.SearchString != null)
            {
                restaurants = this.restaurantsService.GetRestaurantsFromSearch(restaurantIndexViewModel.SearchString, null).ToArray();
            }

            restaurants = this.restaurantsService.SortBy(restaurants.ToArray(), restaurantIndexViewModel.Sorter).ToArray();

            var pageNumber = restaurantIndexViewModel.PageNumber ?? ModelConstants.DefaultPageNumber;
            var pageSize   = restaurantIndexViewModel.PageSize ?? ModelConstants.DefaultPageSize;
            var pageDestinationsViewModel = restaurants.ToPagedList(pageNumber, pageSize);

            restaurantIndexViewModel.RestaurantViewModels = pageDestinationsViewModel;

            return(this.View(restaurantIndexViewModel));
        }
Ejemplo n.º 5
0
        // GET: Restaurant
        public ActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (!(User.IsInRole("RestaurantManager") || User.IsInRole("RestaurantEmployee")))
            {
                return(HttpNotFound());
            }
            if (User.IsInRole("RestaurantEmployee"))
            {
                return(RedirectToAction("DisplayMyRestaurants", "Restaurant"));
            }

            //User is Restaurant Manager
            //set up a viewModel with both active and inactive restaurants
            var userId            = User.Identity.GetUserId();
            var activeRestaurants = db.Restaurants
                                    .Include(r => r.Address)
                                    .Include(r => r.PendingEmployees)
                                    .Include(r => r.ConfirmedEmployees)
                                    .Include(r => r.Subscription)
                                    .Where(r => r.UserId == userId)
                                    .Where(r => r.Subscription.IsActive == true)
                                    .ToList();

            var inactiveRestaurants = db.Restaurants
                                      .Include(r => r.Address)
                                      .Include(r => r.PendingEmployees)
                                      .Include(r => r.ConfirmedEmployees)
                                      .Include(r => r.Subscription)
                                      .Where(r => r.UserId == userId)
                                      .Where(r => r.Subscription.IsActive == false || r.Subscription == null)
                                      .ToList();

            RestaurantIndexViewModel viewModel = new RestaurantIndexViewModel();

            viewModel.ActiveRestaurants   = activeRestaurants;
            viewModel.InactiveRestaurants = inactiveRestaurants;

            return(View(viewModel));
        }
Ejemplo n.º 6
0
        // GET: Restaurant
        // Toon in een lijst alle restauranten
        public ActionResult Index()
        {
            // stopt een lijst van alle restaurants
            List <Restaurant> restaurants = _restaurantRepo.RestaurantList();

            // stopt een lijst met cuisine voor in de filter
            List <String> allFoodTypes = _restaurantRepo.GetAllFoodTypes();

            // vullen de lijst met foodtpe waarde
            var selectlistitems = allFoodTypes.Select(foodType => new SelectListItem()
            {
                Value = foodType, Text = foodType
            });

            if (restaurants == null || allFoodTypes == null || selectlistitems == null)
            {
                return(RedirectToAction("PageNotFound", "Home"));
            }

            // stopt alle models in de viewemodel
            RestaurantIndexViewModel viewModel = new RestaurantIndexViewModel(restaurants, selectlistitems);

            return(View(viewModel));
        }