public List<Animal> SearchAnimals(AnimalDirectoryRequest req) { var Animals = zooDB.Animals .Where(a => req.AnimalID == null ? true : a.AnimalId == req.AnimalID) .Where(a => req.Name == "" ? true : a.Name == req.Name) .Where(a => req.Type == "" ? true : a.Type == req.Type) .Where(a => req.ZooKeeper == null ? true : a.Zookeeper == req.ZooKeeper); return Animals.ToList(); }
public ActionResult SearchAnimalDirectory(AnimalDirectoryRequest request) { AnimalDirectoryModel model = new AnimalDirectoryModel(); model.Animals = SearchAnimals(request); return PartialView("AnimalDirectoryGrid", model); }