public ViewResult Index([FromUri]SongInfo songinfo) { IQueryable<SongInfo> searchResult = this.songsViewModel.Songs.AsQueryable(); //filtering the songs list #region search filters if (songinfo.SongName != "" && songinfo.SongName != null) { searchResult = searchResult .Where(s => s.SongName.Contains(songinfo.SongName)); } if (songinfo.Author != "" && songinfo.Author != null) { searchResult = searchResult .Where(s => s.Author.Contains(songinfo.Author)); } if (songinfo.Genre != "" && songinfo.Genre != null) { searchResult = searchResult .Where(s => s.Genre.Contains(songinfo.Genre)); } if (songinfo.Date != "" && songinfo.Date != null) { searchResult = searchResult .Where(s => s.Date.Contains(songinfo.Date)); } if (songinfo.Durration != "" && songinfo.Durration != null) { searchResult = searchResult .Where(s => s.Durration.Contains(songinfo.Durration)); } #endregion List<SongInfo> list = searchResult.ToList(); //splitting on pages SongViewModel model = new SongViewModel() { Songs = list, }; return View(model); }
public HomeController(ISongsRepository repo) { this.repository = repo; this.songsViewModel = new SongViewModel(this.repository); }