Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IActionResult Index(string Searchtext)
- {
- if(Searchtext == null)
- {
- ViewBag.Title = "Movies";
- var movies = (from m in FakeDatabase.Movies
- select new MovieViewModel
- {
- Id = m.Id,
- Title = m.Title,
- Genre = m.Genre,
- Rating = m.Rating
- }).ToList();
- return View(movies);
- }
- else
- {
- ViewBag.Title = "Movies";
- var filteredMovies = (from m in FakeDatabase.Movies
- where m.Title.ToLower().Contains(Searchtext.ToLower())
- select new MovieViewModel
- {
- Id = m.Id,
- Title = m.Title,
- Genre = m.Genre,
- Rating = m.Rating
- }).ToList();
- return View(filteredMovies.ToList());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement