Exemple #1
0
            /// <summary>
            /// Reads information about specific movies based on the query parameters.
            /// </summary>
            /// <param name="limit">The amount of movies to be returned by the query.</param>
            /// <param name="page">The set of movies to display (eg limit=15 and set=2 will show you movies 15-30).</param>
            /// <param name="quality">The quality type to filter by.</param>
            /// <param name="minimumRating">The minimum movie rating for display (0-9, inclusive).</param>
            /// <param name="queryTerm">The keywords to search by (maybe be multiple keywords, eg. britney, spears).</param>
            /// <param name="genre">The genre from which to display movies from.</param>
            /// <param name="sortBy">The sorting parameter.</param>
            /// <param name="orderBy">The order in which the movies will be displayed.</param>
            /// <returns>A list of movies that match the query parameters.</returns>
            public static List <Movie> ListMovies(byte limit = 20, uint page = 1,
                                                  DirectTorrent.Logic.Models.Quality quality = DirectTorrent.Logic.Models.Quality.ALL, byte minimumRating = 0, string queryTerm = "", string genre = "ALL",
                                                  DirectTorrent.Logic.Models.Sort sortBy     = DirectTorrent.Logic.Models.Sort.DateAdded, DirectTorrent.Logic.Models.Order orderBy = DirectTorrent.Logic.Models.Order.Descending)
            {
                var temp = new List <Movie>();
                // Queries Yify for movies
                var source = ApiWrapper.ListMovies(Format.JSON, limit, page, qualityToQuality(quality), minimumRating, queryTerm, genre,
                                                   sortToSort(sortBy), orderToOrder(orderBy));

                // Maps DTOs to business models
                source.Data.Movies.ForEach(x =>
                {
                    var tempMov = new Movie(x);
                    temp.Add(tempMov);
                });
                return(temp);
            }
Exemple #2
0
            private static DirectTorrent.Data.Yify.Models.Sort sortToSort(DirectTorrent.Logic.Models.Sort sort)
            {
                switch (sort)
                {
                case Logic.Models.Sort.Title:
                    return(Data.Yify.Models.Sort.Title);

                case Logic.Models.Sort.Year:
                    return(Data.Yify.Models.Sort.Year);

                case Logic.Models.Sort.Rating:
                    return(Data.Yify.Models.Sort.Rating);

                case Logic.Models.Sort.DownloadCount:
                    return(Data.Yify.Models.Sort.DownloadCount);

                case Logic.Models.Sort.DateAdded:
                    return(Data.Yify.Models.Sort.DateAdded);
                }
                throw new ArgumentException("Sort is not valid.", "sort");
            }