public void GetWanted(Action<IList<Movie>, Exception> callback)
        {
            // Use this to create design time data
            var result = new List<Movie>();

            // Create 15 new movies
            for (var index = 0; index < 15; index++)
            {
                var movie = new Movie
                {
                    Name = ("Name Wanted " + index).ToUpper(),
                    Plot = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting",
                    Art = "http://nas.blackjid.info:5050/7c9fad341b764a5f8c4781c76f3cbc24/file.cache/0e805a1c080eee97ae227f73cd5b02fc.jpg",
                    Year = 2011,
                    ImdbRating = 7.5,
                    ImdbRatingCount = 0,
                    RottenRating = 86,
                    RottenRatingCount = 0,
                    Backdrop = couch.FileCache("/root/.couchpotato/cache/e6317f1d41614f9c9567c3a5a01ce45d.jpg")
                };

                result.Add(movie);
            }

            callback(result, null);
        }
Example #2
0
        public void GetMovies(Action<IList<Movie>, Exception> callback)
        {
            GlobalLoading.Instance.IsLoading = true;

            // Create the client
            WebClient client = new WebClient();

            // Process the response from the server
            client.DownloadStringCompleted += (sender, e) =>
            {
                if (e.Error != null)
                {
                    callback(null, e.Error);
                    return;
                }

                // A list to store the movies
                var result = new List<Movie>();

                // Parse the json response
                JObject o = JObject.Parse(e.Result);
                foreach (JToken jtMovie in o["movies"])
                {
                    // Create the movies
                    var movie = new Movie();
                    movie.Name = ((string)jtMovie["library"]["titles"][0]["title"]).ToUpper();
                    movie.Plot = (string)jtMovie["library"]["plot"];
                    movie.Art = App.Current.Couch.FileCache((string)jtMovie["library"]["files"][0]["path"]);
                    movie.Year = (int)jtMovie["library"]["year"];
                    if (jtMovie["library"]["info"]["rating"]["imdb"][0].ToString() != "N/A")
                        movie.ImdbRating = (double)jtMovie["library"]["info"]["rating"]["imdb"][0];
                    else
                        movie.ImdbRating = 0;
                    if (jtMovie["library"]["info"]["rating"]["imdb"][1].ToString() != "N/A")
                        movie.ImdbRatingCount = (int)jtMovie["library"]["info"]["rating"]["imdb"][1];
                    else
                        movie.ImdbRatingCount = 0;
                    movie.RottenRating = (int)jtMovie["library"]["info"]["rating"]["rotten"][0];
                    movie.RottenRatingCount = (int)jtMovie["library"]["info"]["rating"]["rotten"][1];
                    movie.Backdrop = App.Current.Couch.FileCache((string)jtMovie["library"]["files"][2]["path"]);

                    result.Add(movie);
                }

                GlobalLoading.Instance.IsLoading = false;

                callback(result, null);
            };

            // Make the call to the server
            client.DownloadStringAsync(App.Current.Couch.MovieList("done"));
        }
 /// <summary>
 /// Initializes a new instance of the MovieViewModel class.
 /// </summary>
 public MovieViewModel(Movie model)
 {
     Model = model;
 }