// Displays data from the stored data context and binding collection public void LoadData(NetflixCatalog context, DataServiceCollection <Title> _titles) { _context = context; Titles = _titles; IsDataLoaded = true; }
private Task <QueryOperationResponse <Title> > GetQueryResults(int start, int pageSize, IList <SortDescription> sortDescriptions) { var context = new NetflixCatalog(new Uri("http://odata.netflix.com/Catalog")); var orderByString = CreateOrderByString(sortDescriptions); var query = context.Titles .AddQueryOption("$skip", start) .AddQueryOption("$top", pageSize) .IncludeTotalCount(); if (!string.IsNullOrEmpty(Search)) { query = query.AddQueryOption("$filter", "(substringof('" + Search + "',Name) eq true) and (BoxArt/SmallUrl ne null)"); } else { query = query.AddQueryOption("$filter", "(BoxArt/SmallUrl ne null)"); } if (orderByString.Length > 0) { query = query.AddQueryOption("$orderby", orderByString); } return(Task.Factory.FromAsync <IEnumerable <Title> >(query.BeginExecute, query.EndExecute, null) .ContinueWith(t => (QueryOperationResponse <Title>)t.Result, TaskContinuationOptions.ExecuteSynchronously)); }
/// <summary> /// Invoked when a filter is selected using the ComboBox in snapped view state. /// </summary> /// <param name="sender">The ComboBox instance.</param> /// <param name="e">Event data describing how the selected filter was changed.</param> void Filter_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Determine what filter was selected var selectedFilter = e.AddedItems.FirstOrDefault() as Filter; if (selectedFilter != null) { // Mirror the results into the corresponding Filter object to allow the // RadioButton representation used when not snapped to reflect the change selectedFilter.Active = true; // TODO: Respond to the change in active filter by setting this.DefaultViewModel["Results"] // to a collection of items with bindable Image, Title, Subtitle, and Description properties DefaultViewModel["Results"] = null; // clear previous result DefaultViewModel["Results"] = new ObservableCollection <SearchResult>(); var searchText = DefaultViewModel["QueryText"] as string; if (!String.IsNullOrEmpty(searchText)) { NetflixCatalog catalog = new NetflixCatalog(netflixServiceUri); var query = catalog.Titles.Where(t => t.Name.Contains(searchText)).Select(t => t); var queryResults = new DataServiceCollection <Title>(); queryResults.LoadCompleted += (o, args) => { if (queryResults.Continuation != null) { queryResults.LoadNextPartialSetAsync(); } else { DefaultViewModel["Results"] = queryResults.Select(t => new { Title = t.Name, Subtitle = t.ShortName, Description = t.ShortSynopsis, Image = t.BoxArt.MediumUrl }).ToList(); // ensure that results are found object results; ICollection resultsCollection; if (this.DefaultViewModel.TryGetValue("Results", out results) && (resultsCollection = results as ICollection) != null && resultsCollection.Count != 0) { VisualStateManager.GoToState(this, "ResultsFound", true); } } }; queryResults.LoadAsync(query); } } // Display informational text when there are no search results. VisualStateManager.GoToState(this, "NoResultsFound", true); }
// Loads data when the application is initialized. public void LoadData() { // Instantiate the context and binding collection. _context = new NetflixCatalog(_rootUri); // Use the public property setter to generate a notification to the binding. Titles = new DataServiceCollection <Title>(_context); // Load the data. Titles.LoadAsync(GetQuery()); }
public MainViewModel() { // Instantate the DataContext. localDb = new NetflixCatalogLocalDB(); // Instantiate the context and binding collection using the stored URI. this._context = new NetflixCatalog(_rootUri); appSettings = IsolatedStorageSettings.ApplicationSettings; _currentPage = 0; }
private void LoadTitles() { var netflix = new NetflixCatalog( new Uri( "http://odata.netflix.com/Catalog/", UriKind.Absolute)); _collection = new DataServiceCollection <Title>(netflix); TitleGrid.ItemsSource = _collection; _collection.LoadCompleted += Collection_LoadCompleted; var query = (from t in netflix.Titles where t.Name.StartsWith("Y") orderby t.Rating descending select t).Take(100); _collection.LoadAsync(query); }
public void Test() { NetflixCatalog catalog = new NetflixCatalog(new Uri("http://odata.netflix.com/Catalog/")); var genres = catalog.Genres; foreach (var genre in genres) { var titles = (from g in catalog.Genres from t in g.Titles where g.Name == genre.Name orderby t.AverageRating select t).Take(5).ToList(); foreach (var title in titles) { Console.WriteLine(title.Name); } } Console.ReadKey(); /* * var netflixHandler = new NetflixHandler(); * netflixHandler.AuthorizeApplication(); */ /* * var netflixHandler = new NetflixHandler("BQAJAAEDEIaBzuE0b4OPHh2zgQATfaEwMNpxVnrIfaGpdQh2Tg_xyqZjPciEkA_8R_h4fHDlqkm-DPSIteMq-1wQVcinZQ_s", "XZaGwr2dyCZv", "BQAJAAEDEJbwpIepbc796kRNRvsfSeMgEt2HEO71RZl9eyMgvhYebbu8ujHAGcdWGg09w23z6LE."); * netflixHandler.Users.RequestAvailableQueues(); * netflixHandler.Catalog.RequestCatalogTitles(); * * /* * var oauthHandler = new OAuthHandler(); * * oauthHandler.Config.RequestTokenUri = new Uri(REQUEST_TOKEN_URL); * oauthHandler.Config.AccessTokenUri = new Uri(ACCESS_TOKEN_URL); * * oauthHandler.Config.ApplicationName = "QuikPix for Netflix"; * * oauthHandler.Config.OAuthConsumerKey = consumerKey; * oauthHandler.Config.OAuthConsumerSecret = consumerSecret; * var responseR = oauthHandler.GetRequestToken(); * string loginUrl = responseR["login_url"] + "&oauth_consumer_key=" + consumerKey; * * Process.Start(loginUrl); * * * Console.WriteLine(responseR.ToString()); * Console.ReadLine(); * Console.WriteLine("--------------------"); * * var responseA = oauthHandler.GetAccessToken(); * * Console.WriteLine(responseA.ToString()); * Console.ReadLine(); * Console.WriteLine("--------------------"); * * Console.WriteLine("Done"); * * Console.ReadLine(); */ }
/// <summary> /// Initializes a new instance of the <see cref="ServiceManager"/> class. /// </summary> public ServiceManager() { _netflixCatalog = new NetflixCatalog(new Uri("http://odata.netflix.com/v2/Catalog/"), UriKind.Absolute); }