Beispiel #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 <SpeciesModel> > DisplayAllSpecies(List <SpeciesModel> species)
        {
            string lookUpAnother = "";

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

                    SpeciesModel sp = await GetSingleSpecies(idText);

                    List <PersonModel> person = await CharacterController.GetStarWarsCharacters(sp.People);

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

                    PlanetModel planet = await PlanetController.GetSpeciesHomeworld(sp.Homeworld);

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Name: {sp.Name} | Classification: {sp.Classification}");
                    Console.WriteLine($"Designation: {sp.Designation} | Average Height: {sp.AverageHeight}cm");
                    Console.WriteLine($"Skin Colors: {sp.SkinColors}");
                    Console.WriteLine($"Hair Colors: {sp.HairColors}");
                    Console.WriteLine($"Eye Colors: {sp.EyeColors}");
                    Console.WriteLine($"Average Lifespan: {sp.AverageLifespan} years");
                    Console.WriteLine($"Homeworld: {planet.Name} | Language: {sp.Language}");
                    Console.WriteLine($"People: {CharacterController.FormatPersonLine(person)}");
                    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 == "y");

            return(null);
        }
Beispiel #3
0
        public static async Task <List <VehicleModel> > DisplayAllVehicles(List <VehicleModel> vehicles)
        {
            string lookUpAnother = "";

            do
            {
                try
                {
                    foreach (VehicleModel v in vehicles)
                    {
                        string id = v.Url.Split('/')[5];
                        v.Id = id;
                        Console.WriteLine($"{ v.Id } { v.Name }");
                    }

                    Console.Write("\nPlease enter and ID number: ");
                    string idText = Console.ReadLine();

                    VehicleModel vehicle = await GetSingleVehicle(idText);

                    List <PersonModel> person = await CharacterController.GetStarWarsCharacters(vehicle.Pilots);

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

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Name: {vehicle.Name} | Model: {vehicle.Model}");
                    Console.WriteLine($"Manufacturer: {vehicle.Manufacturer} | Class: {vehicle.VehicleClass}");
                    Console.WriteLine($"Cost: {vehicle.CostInCredits} | Cargo Capacity: {vehicle.CargoCapacity}");
                    Console.WriteLine($"Consumables: {vehicle.Consumables} | Max Speed: {vehicle.MaxAtmospheringSpeed} | Length: {vehicle.Length}m");
                    Console.WriteLine($"Crew: {vehicle.Crew} | Passengers: {vehicle.Passengers}");
                    Console.WriteLine($"Pilots: {CharacterController.FormatPersonLine(person)}");
                    Console.WriteLine($"Films: {FilmController.FormatFilmLine(film)}");
                    Console.WriteLine(String.Format("{0:N}", Convert.ToInt32(vehicle.CargoCapacity)));
                    Console.WriteLine(String.Format("{0:#,##0.##}", Convert.ToInt32(vehicle.CargoCapacity)));
                    Console.WriteLine("============================================================");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error: { ex.Message }");
                }

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

            return(null);
        }
Beispiel #4
0
        public static async Task <List <StarshipModel> > DisplayAllStarships(List <StarshipModel> starships)
        {
            string lookUpAnother = "";

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

                    StarshipModel starship = await GetSingleStarship(idText);

                    List <PersonModel> person = await CharacterController.GetStarWarsCharacters(starship.Pilots);

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

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Name: {starship.Name} | Model: {starship.Model}");
                    Console.WriteLine($"Manufacturer: {starship.Manufacturer} | Class: {starship.StarshipClass}");
                    Console.WriteLine($"Cost: {starship.CostInCredits} | Cargo Capacity: {starship.CargoCapacity}");
                    Console.WriteLine($"Consumables: {starship.Consumables} | Max Speed: {starship.MaxAtmospheringSpeed}");
                    Console.WriteLine($"Hyperdrive: {starship.HyperdriveRating} | MGLT: {starship.MGLT} | Length: {starship.Length}");
                    Console.WriteLine($"Crew: {starship.Crew} | Passengers: {starship.Passengers}");
                    Console.WriteLine($"Pilots: {CharacterController.FormatPersonLine(person)}");
                    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 == "y");

            return(null);
        }
        public static async Task <List <PlanetModel> > DisplayAllPlanets(List <PlanetModel> planets)
        {
            string lookUpAnother = "";

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

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

                    PlanetModel planet = await GetStarWarsPlanets(idText);

                    List <PersonModel> person = await CharacterController.GetStarWarsCharacters(planet.Residents);

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

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Name: {planet.Name} | Diameter: {planet.Diameter} | Population: {planet.Population}");
                    Console.WriteLine($"It's terrain is {planet.Terrain}, surface water of {planet.SurfaceWater} with {planet.Gravity} gravity  \nand the climate is {planet.Climate}");
                    Console.WriteLine($"{planet.Name} orbits every {planet.OrbitalPeriod} days and rotates every {planet.RotationPeriod} hours");
                    Console.WriteLine($"Residents: {CharacterController.FormatPersonLine(person)}");
                    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 planet (y/n)? ");
                lookUpAnother = Console.ReadLine();
            } while (lookUpAnother.ToLower() == "y");

            return(null);
        }