public IActionResult Selection() { GoatSelectionVM GoatSelection = new GoatSelectionVM(); GoatSelection.GoatBreeds = new SelectList(_repo.GoatBreed.GetModel(), "BreedName", "BreedName"); IEnumerable <GoatRegistration> Goats = _repo.GoatRegistration.GetModel().AsEnumerable(); IEnumerable <GoatBreed> GoatBreed = _repo.GoatBreed.GetModel().AsEnumerable(); IEnumerable <GoatIndexVM> Goatss = (from g in Goats from b in GoatBreed where g.GoatBreedId == b.Id select new GoatIndexVM { Goat = g, Breed = b }); GoatSelection.GoatIndex = Goatss; return(View(GoatSelection)); }
public IActionResult Selection(GoatSelectionVM selectionVM) { GoatSelectionVM GoatSelection = new GoatSelectionVM(); GoatSelection = selectionVM; GoatSelection.GoatBreeds = new SelectList(_repo.GoatBreed.GetModel(), "BreedName", "BreedName"); IEnumerable <GoatRegistration> Goats = _repo.GoatRegistration.GetModel().AsEnumerable(); IEnumerable <GoatBreed> GoatBreed = _repo.GoatBreed.GetModel().AsEnumerable(); IEnumerable <GoatIndexVM> Goatss = (from g in Goats from b in GoatBreed where g.GoatBreedId == b.Id select new GoatIndexVM { Goat = g, Breed = b }); GoatSelection.GoatIndex = Goatss; if (!string.IsNullOrEmpty(selectionVM.MainPurpose)) { GoatSelection.GoatIndex = GoatSelection.GoatIndex.Where(m => m.Goat.MainPurpose == selectionVM.MainPurpose); } if (!string.IsNullOrEmpty(selectionVM.Weather)) { GoatSelection.GoatIndex = GoatSelection.GoatIndex.Where(m => m.Goat.Weather == selectionVM.Weather); } if (!string.IsNullOrEmpty(selectionVM.Availability)) { GoatSelection.GoatIndex = GoatSelection.GoatIndex.Where(m => m.Goat.Availability == selectionVM.Availability); } if (!string.IsNullOrEmpty(selectionVM.GoatBreed)) { GoatSelection.GoatIndex = GoatSelection.GoatIndex.Where(m => m.Breed.BreedName == selectionVM.GoatBreed); } return(View(GoatSelection)); }