Ejemplo n.º 1
0
        internal static List <Film> sortFilmsByCompany()
        {
            List <Film>   allFilms  = FilmLibraryService.getAllFilms();
            List <string> companies = new List <string>();

            foreach (var film in allFilms)
            {
                companies.Add(film.Company);
            }
            companies.Sort();

            List <string> distinct        = companies.Distinct().ToList();
            List <Film>   sortedByCompany = new List <Film>();

            foreach (var company in distinct)
            {
                foreach (var film in allFilms)
                {
                    if (company == film.Company)
                    {
                        sortedByCompany.Add(film);
                    }
                }
            }
            return(sortedByCompany);
        }
Ejemplo n.º 2
0
        internal static List <Film> sortFilmsByYear()
        {
            List <Film> allFilms = FilmLibraryService.getAllFilms();
            List <int>  years    = new List <int>();

            foreach (var film in allFilms)
            {
                years.Add(film.Year);
            }
            years.Sort();

            List <int>  distinct     = years.Distinct().ToList();
            List <Film> sortedByYear = new List <Film>();

            foreach (var year in distinct)
            {
                foreach (var film in allFilms)
                {
                    if (year == film.Year)
                    {
                        sortedByYear.Add(film);
                    }
                }
            }
            return(sortedByYear);
        }
Ejemplo n.º 3
0
        internal static List <Film> sortFilmsByDuration()
        {
            List <Film> allFilms  = FilmLibraryService.getAllFilms();
            List <int>  durations = new List <int>();

            foreach (var film in allFilms)
            {
                durations.Add(film.DurationInMinutes);
            }
            durations.Sort();

            List <int>  distinct         = durations.Distinct().ToList();
            List <Film> sortedByDuration = new List <Film>();

            foreach (var duration in distinct)
            {
                foreach (var film in allFilms)
                {
                    if (duration == film.DurationInMinutes)
                    {
                        sortedByDuration.Add(film);
                    }
                }
            }
            return(sortedByDuration);
        }
Ejemplo n.º 4
0
        internal static List <Film> sortFilmsByQuality()
        {
            List <Film> allFilms  = FilmLibraryService.getAllFilms();
            List <int>  qualities = new List <int>();

            foreach (var film in allFilms)
            {
                qualities.Add(film.Quality);
            }
            qualities.Sort();

            List <int>  distinct        = qualities.Distinct().ToList();
            List <Film> sortedByQuality = new List <Film>();

            foreach (var quality in distinct)
            {
                foreach (var film in allFilms)
                {
                    if (quality == film.Quality)
                    {
                        sortedByQuality.Add(film);
                    }
                }
            }
            return(sortedByQuality);
        }
Ejemplo n.º 5
0
        internal static List <Film> sortFilmsByFormat()
        {
            List <Film>   allFilms = FilmLibraryService.getAllFilms();
            List <string> formats  = new List <string>();

            foreach (var film in allFilms)
            {
                formats.Add(film.Format);
            }
            formats.Sort();

            List <string> distinct       = formats.Distinct().ToList();
            List <Film>   sortedByFormat = new List <Film>();

            foreach (var format in distinct)
            {
                foreach (var film in allFilms)
                {
                    if (format == film.Format)
                    {
                        sortedByFormat.Add(film);
                    }
                }
            }
            return(sortedByFormat);
        }
Ejemplo n.º 6
0
        internal static List <Film> sortFilmsByTitle()
        {
            List <Film>   allFilms = FilmLibraryService.getAllFilms();
            List <string> titles   = new List <string>();

            foreach (var film in allFilms)
            {
                titles.Add(film.Title);
            }
            titles.Sort();

            List <string> distinct      = titles.Distinct().ToList();
            List <Film>   sortedByTitle = new List <Film>();

            foreach (var title in distinct)
            {
                foreach (var film in allFilms)
                {
                    if (title == film.Title)
                    {
                        sortedByTitle.Add(film);
                    }
                }
            }
            return(sortedByTitle);
        }