public IActionResult Search() { VideoSearchViewModel videoSearchViewModel = new VideoSearchViewModel(); List <Video> list = new List <Video>(); videoSearchViewModel.List = list; return(View(videoSearchViewModel)); }
public ActionResult Index(VideoSearchViewModel search) { List <VideoSearchViewModel> vids = (from v in db.Videos where (v.name.ToLower().Contains(search.name.ToLower() ?? v.name.ToLower())) && (v.location.ToLower().Contains(search.location.ToLower() ?? v.location.ToLower())) select new VideoSearchViewModel { id = v.id, name = v.name, location = v.location, contentType = v.contentType }).ToList(); search.catList.Remove(0); List <int> catId = (from c in db.Cats where (c.sex.ToLower().Contains(search.catSex)) || (c.age.Contains(search.catAge)) select c.id).ToList(); search.catList = search.catList.Concat(catId).ToList(); if (search.catBreed.Count() > 0) { catId = (from c in db.Cats where search.catBreed.Contains(c.breed) select c.id).ToList(); search.catList = search.catList.Concat(catId).ToList(); } if (search.catList.Count() > 0) { List <int> catVideoId = (from j in db.Video_Cat_Junction where search.catList.Contains(j.cat_id) select j.video_id).ToList(); vids = (from v in vids where catVideoId.Contains(v.id) select v).ToList(); } populateLists(); return(View(vids)); }
public IActionResult Search(VideoSearchViewModel videoSearchViewModel) { VideoSearch items = new VideoSearch(); List <Video> list = new List <Video>(); foreach (var item in items.SearchQuery(videoSearchViewModel.SearchText, 1)) { Video video = new Video(); video.Title = item.Title; video.Author = item.Author; video.Url = item.Url; video.Thumbnail = item.Thumbnail; list.Add(video); } videoSearchViewModel.List = list; return(View(videoSearchViewModel)); }