Example #1
0
        public static async Task <List <PersonModel> > DisplayAllCharacters(List <PersonModel> people)
        {
            string lookUpAnother = "";

            do
            {
                try
                {
                    foreach (PersonModel p in people)
                    {
                        string id = p.Url.Split('/')[5];
                        p.Id = id;
                        Console.WriteLine($"{p.Id} {p.FullName}");
                    }

                    Console.Write("\nPlease enter an ID number (1-88): ");
                    string idText = Console.ReadLine();

                    PersonModel person = await GetStarWarsCharacter(idText);

                    PlanetModel planet = await PlanetController.GetStarWarsPlanets(person.Homeworld);

                    List <VehicleModel> vehicle = await VehicleController.GetStarWarsVehicles(person.Vehicles);

                    List <StarshipModel> starship = await StarshipController.GetStarWarsStarShips(person.Starships);

                    List <FilModel> film = await FilmController.GetStarWarsFilms(person.Films);

                    List <SpeciesModel> species = await SpeciesController.GetStarWarsSpecies(person.Species);

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Name: { person.FullName } | Gender: { person.Gender }");
                    Console.WriteLine($"Species: { SpeciesController.FormatSpeciesLine(species) } race");
                    Console.WriteLine($"Born: { person.BirthYear }");
                    Console.WriteLine($"Homeworld: { planet.Name }");
                    Console.WriteLine($"{ FormatMeasurementLine(person) }");
                    Console.WriteLine($"Hair: { person.HairColor } | Skin: { person.SkinColor } | " +
                                      $"Eyes: { person.Eye_Color}");

                    Console.WriteLine($"Vehicles: { VehicleController.FormatVehicleLine(vehicle) }");
                    Console.WriteLine($"Starships: { StarshipController.FormatStarshipLine(starship) }");
                    Console.WriteLine($"Films: { FilmController.FormatFilmLine(film) }");
                    Console.WriteLine("============================================================");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error: { ex.Message }");
                }

                Console.Write("Do you want to look up another character (y/n)?");
                lookUpAnother = Console.ReadLine();
            } while (lookUpAnother.ToLower() == "y");

            return(null);
        }
        public static async Task <List <FilModel> > DisplayAllFilms(List <FilModel> films)
        {
            string lookUpAnother = "";

            do
            {
                try
                {
                    foreach (FilModel f in films)
                    {
                        string id = f.Url.Split('/')[5];
                        f.Id = id;
                        Console.WriteLine($"{f.Id} {f.Title}");
                    }
                    Console.Write("\nPlease enter an ID number: ");
                    string idText = Console.ReadLine();

                    FilModel film = await GetSingleFilm(idText);

                    List <PersonModel> person = await CharacterController.GetStarWarsCharacters(film.Characters);

                    List <PlanetModel> planet = await PlanetController.GetStarWarsPlanetArray(film.Planets);

                    List <SpeciesModel> species = await SpeciesController.GetStarWarsSpecies(film.Species);

                    List <StarshipModel> starship = await StarshipController.GetStarWarsStarShips(film.Starships);

                    List <VehicleModel> vehicle = await VehicleController.GetStarWarsVehicles(film.Vehicles);

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Title: {film.Title} | Release Date: {film.ReleaseDate}");
                    Console.WriteLine($"Producer: {film.Producer} | Director: {film.Director}");
                    Console.WriteLine($"    Opening Crawl: \n{film.OpeningCrawl}");
                    Console.WriteLine($"Characters: {CharacterController.FormatPersonLine(person)}");
                    Console.WriteLine($"Planets: {PlanetController.FormatPlanetLine(planet)}");
                    Console.WriteLine($"Starships: {StarshipController.FormatStarshipLine(starship)}");
                    Console.WriteLine($"Vehicles: {VehicleController.FormatVehicleLine(vehicle)}");
                    Console.WriteLine($"Species: {SpeciesController.FormatSpeciesLine(species)}");
                    Console.WriteLine("============================================================");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error: {ex.Message}");
                }

                Console.Write("Do you want to look up another character (y/n)?");
                lookUpAnother = Console.ReadLine();
            } while (lookUpAnother == "y");

            return(null);
        }