public List <Movie> QueryByGenre(Enum.Genre genre) { List <Movie> movies = SelectAll(); List <Movie> sorted = new List <Movie>(); foreach (Movie movie in movies) { foreach (Enum.Genre gen in movie.Genre) { if (gen.Equals(genre)) { sorted.Add(movie); break; } } } return(sorted); }
private static void SortQueryMovies() { MovieBusiness movieBusiness = new MovieBusiness(_repository); bool response = false; using (movieBusiness) { while (!response) { switch (ConsoleView.GetSortQueryChoice(out response)) { case Enum.ManagerAction.QueryPersonByRole: Enum.Role role = ConsoleView.RoleChoice(); string name = ConsoleView.GetNameQuery(role); if (role != Enum.Role.None && name != null) { ConsoleView.BrowseAllMovies(movieBusiness.QueryPersonByRole(role, name), false, "Query: " + role + " " + name); } break; case Enum.ManagerAction.QueryByFirstLetter: char letter = ConsoleView.GetLetterQuery(); if (letter != '\u0000') { ConsoleView.BrowseAllMovies(movieBusiness.QueryByFirstLetter(letter), false, "Query First Letter: " + letter); } break; case Enum.ManagerAction.QueryByGenre: Enum.Genre gen = ConsoleView.GetGenreQuery(); if (gen != Enum.Genre.None) { ConsoleView.BrowseAllMovies(movieBusiness.QueryByGenre(gen), false, "Query Genre: " + gen); } break; case Enum.ManagerAction.QueryByReleaseYear: int year = ConsoleView.GetYearQuery(); if (year != -1) { ConsoleView.BrowseAllMovies(movieBusiness.QueryByReleaseYear(year), true, "Query Release Year: " + year); } break; case Enum.ManagerAction.SortByAscendingTitle: ConsoleView.BrowseAllMovies(movieBusiness.SortByAscendingTitle(), false, "Ascending Title"); break; case Enum.ManagerAction.SortByDescendingTitle: ConsoleView.BrowseAllMovies(movieBusiness.SortByDescendingTitle(), false, "Descending Title"); break; case Enum.ManagerAction.SortByAscendingYear: ConsoleView.BrowseAllMovies(movieBusiness.SortByAscendingYear(), true, "Ascending Year"); break; case Enum.ManagerAction.SortByDescendingYear: ConsoleView.BrowseAllMovies(movieBusiness.SortByDescendingYear(), true, "Descending Year"); break; default: //ConsoleView.DisplayMessage(""); //ConsoleView.DisplayMessage(""); //ConsoleView.DisplayMessage("It appears you have selected an incorrect choice."); //ConsoleView.DisplayContinuePrompt(); break; } } } }