Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            SolarSystemDbContext ct = new SolarSystemDbContext();

            //PrintList(OrderByAmountOfMoonsOfDwarfPlanets(ct), p => $"{p.Name} has {p.NumberOfMoons} moon(s).");
            //PrintList(OrderByOrbitalDistance(ct), p => $"{p.Name} has an orbital distance of {p.OrbitDistance} km.");
            //Console.WriteLine($"There are {AmountOfMoonsSolarSystem(ct)} moons in the solar system.");
            //PrintList(OrderDwarfPlanetsByDiameter(ct), dp => $"{dp.Name} has a diameter of {dp.Diameter} km");
            //Console.WriteLine($"{AverageAmountOfMoonsPerDwarfPlanet(ct)} moons per dwarf planet");
            PrintList(AverageSurfaceTemperaturesPerTypeOfObject(ct), d => d);
        }
Example #2
0
        private static List <string> AverageSurfaceTemperaturesPerTypeOfObject(SolarSystemDbContext ct)
        {
            List <Planet> dwarfPlanets = ct.Planets.Where(p => p.PlanetType == PlanetTypes.DwarfPlanet)
                                         .ToList();

            List <Planet> planets = ct.Planets.Where(p => p.PlanetType == PlanetTypes.Planet)
                                    .ToList();
            Star          sun     = ct.Stars.FirstOrDefault(s => s.Name.Equals("The Sun"));//, StringComparison.Ordinal));
            List <string> display = new List <string>();

            double dwarfAverage  = dwarfPlanets.Average(dp => dp.SurfaceTemperature);
            double planetAverage = planets.Average(p => p.SurfaceTemperature);

            display.Add($"The average surface temperature of all Dwarf Planets is {dwarfAverage} degree celsius");
            display.Add($"The average surface temperature of all Planets is {planetAverage} degree celsius");
            display.Add($"The average surface temperature of the Sun is {sun.SurfaceTemperature.TrimThousands()} degree celsius");

            return(display);
        }
Example #3
0
 private static List <Planet> OrderPlanetsByNameAscending(SolarSystemDbContext ct)
 {
     return(ct.Planets.OrderBy(p => p.Name).ToList());
 }
Example #4
0
 private static List <Planet> AboveZeroDegrees(SolarSystemDbContext ct)
 {
     return(ct.Planets.Where(p => Convert.ToInt32(p.SurfaceTemperatureMax) > 0 || Convert.ToInt32(p.SurfaceTemperatureMin) > 0).ToList());
 }
Example #5
0
 private static List <Planet> PlanetNameWithPandT(SolarSystemDbContext ct)
 {
     return(ct.Planets.Where(p => p.Name.Contains("P") && p.Name.Contains("T")).ToList());
 }
Example #6
0
 private static List <Planet> OrderByPlanetNameLength(SolarSystemDbContext ct)
 {
     return(ct.Planets.OrderByDescending(p => p.Name.Length).ToList());
 }
Example #7
0
 private static List <Planet> OrderByOrbitalDistance(SolarSystemDbContext ct)
 {
     return(ct.Planets.OrderBy(p => Convert.ToInt64(p.OrbitDistance.Replace(",", ""))).ToList());
 }
Example #8
0
 private static List <Planet> OrderByAmountOfMoonsOfDwarfPlanets(SolarSystemDbContext ct)
 {
     return(ct.Planets.Where(p => p.PlanetType == PlanetTypes.DwarfPlanet)
            .OrderByDescending(p => p.NumberOfMoons).ToList());
 }
Example #9
0
 private static int AmountOfMoonsSolarSystem(SolarSystemDbContext ct)
 {
     return(ct.Planets.Sum(p => p.NumberOfMoons));
 }
Example #10
0
 private static List <Planet> OrderDwarfPlanetsByDiameter(SolarSystemDbContext ct)
 {
     return(ct.Planets.Where(p => p.PlanetType == PlanetTypes.DwarfPlanet)
            .OrderByDescending(dp => Convert.ToInt64(dp.Diameter.Replace(",", ""))).ToList());
 }
Example #11
0
        private static float AverageAmountOfMoonsPerDwarfPlanet(SolarSystemDbContext ct)
        {
            List <Planet> dwarfPlanets = ct.Planets.Where(p => p.PlanetType == PlanetTypes.DwarfPlanet).ToList();

            return(Convert.ToInt32(dwarfPlanets.Average(dp => dp.NumberOfMoons)));
        }
Example #12
0
        private static List <Planet> TwoClosestPlanets(SolarSystemDbContext ct)
        {
            List <Planet> planets = ct.Planets.Min(p => Convert.ToDouble(p.OrbitDistance.TrimThousands()))

                                    return
        }