public IActionResult Zoeken(string ZoekSoort = null, string ZoekKey = null, string Categorie = null, string Ligging = null, string MaxStartPrijs = null) { ViewData["AlleCategorien"] = _categorieRepository.GetAll().ToList(); IEnumerable <Bon> GefilterdeBonnen; if (!string.IsNullOrEmpty(ZoekKey)) { switch (ZoekSoort) { case "Alles": GefilterdeBonnen = _bonRepository.GetAlles(ZoekKey, _bonRepository.GetAllGoedgekeurd()); break; case "Ligging": GefilterdeBonnen = _bonRepository.GetByLigging(ZoekKey, _bonRepository.GetAllGoedgekeurd()); break; case "Naam": GefilterdeBonnen = _bonRepository.GetByNaam(ZoekKey, _bonRepository.GetAllGoedgekeurd()); break; case "Categorie": GefilterdeBonnen = _bonRepository.GetByCategorie(ZoekKey, _bonRepository.GetAllGoedgekeurd()); break; default: GefilterdeBonnen = _bonRepository.GetAllGoedgekeurd(); break; } ViewData["ZoekOpdracht"] = ZoekKey + " in " + ZoekSoort; if (!string.IsNullOrEmpty(Categorie) && Categorie != "*") { string input = Categorie; GefilterdeBonnen = _bonRepository.GetByCategorie(input, GefilterdeBonnen); ViewData["ZoekOpdracht"] = ViewData["ZoekOpdracht"] + ", met categorie " + input; } if (!string.IsNullOrEmpty(Ligging) && Ligging != "*") { string input = Ligging; GefilterdeBonnen = _bonRepository.GetByLigging(input, GefilterdeBonnen); ViewData["ZoekOpdracht"] = ViewData["ZoekOpdracht"] + ", met ligging " + input; } if (!string.IsNullOrEmpty(MaxStartPrijs)) { int input = int.Parse(MaxStartPrijs); GefilterdeBonnen = _bonRepository.GetByPrijs(input, GefilterdeBonnen); ViewData["ZoekOpdracht"] = ViewData["ZoekOpdracht"] + ", met maximum prijs €" + input; } } else { GefilterdeBonnen = _bonRepository.GetAllGoedgekeurd(); ViewData["ZoekOpdracht"] = "Overzicht van alle bons"; if (!string.IsNullOrEmpty(Categorie) && Categorie != "*") { string input = Categorie; GefilterdeBonnen = _bonRepository.GetByCategorie(input, GefilterdeBonnen); ViewData["ZoekOpdracht"] = ViewData["ZoekOpdracht"] + ", met categorie " + input; } if (!string.IsNullOrEmpty(Ligging) && Ligging != "*") { string input = Ligging; GefilterdeBonnen = _bonRepository.GetByLigging(input, GefilterdeBonnen); ViewData["ZoekOpdracht"] = ViewData["ZoekOpdracht"] + ", met ligging " + input; } if (!string.IsNullOrEmpty(MaxStartPrijs)) { int input = int.Parse(MaxStartPrijs); GefilterdeBonnen = _bonRepository.GetByPrijs(input, GefilterdeBonnen); ViewData["ZoekOpdracht"] = ViewData["ZoekOpdracht"] + ", met maximum prijs " + input; } } return(View(GefilterdeBonnen.Select(b => new ZoekViewModel(b)).ToList())); }