public PartialViewResult Search(string query = "") { FacebookUser me = (FacebookUser)Session["me"]; // Init lists List<Media> Results = new List<Media>(); List<Media> APIResults = new List<Media>(); List<Media> FriendsAll = new List<Media>(); List<Media> FriendsResults = new List<Media>(); try { // Search API for media to add APIResults = new MediaAPI().Search(query); // Search Friends' shelves foreach (var friend in me.Friends) { foreach (var media in new MediaAPI().GetUserShelf(friend.Id)) { media.Owners.Add(friend); FriendsAll.Add(media); } } // Add my media to owners foreach (var media in new MediaAPI().GetUserShelf(me.Id)) { media.Owners.Add(me); FriendsAll.Add(media); } // Search FriendsResults for owners of APIResults FriendsResults = FriendsAll.Intersect(APIResults, new MediaComparer()).ToList(); // Join results into one list Results = FriendsResults.Union(APIResults, new MediaComparer()).Take(6).ToList(); return PartialView("_SearchResults", Results); } catch { return PartialView("_SearchResults", Results); } }
public PartialViewResult Info(string MediaID, int Type = 1) { FacebookUser me = (FacebookUser)Session["me"]; Media media; if (Type == 1) { media = new MediaAPI().GetMovie(MediaID); } else if (Type == 2) { media = new MediaAPI().GetShow(MediaID); } else { media = new Media(); } return PartialView("_Info", media); }