public SolarSystemModel CreateSmallSolarSystem() { var model = new SolarSystemModel { Name = "Zero planets", TextStyle = { BgrColor = "#002244", FillColor = "#fff", FontSize = 16, FontFamily = "Open Sans" } }; model.Planets.Add(new Planet { Name = "Alfa", OrbitRadius = 142, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 15000 }); model.Planets.Add(new Planet { Name = "Beta", OrbitRadius = 180, OrbitStroke = "rgb(1, 200, 255, 0.7)", RotationDuration = 16000 }); return(model); }
public Task <double> GetAverageAmountOfMoonsByPlanetsInSolarSystem(SolarSystemModel solarSystem) => Task.FromResult( context.PlntAndDPlnt .Where(p => p.SolarSystemToOrbit == solarSystem) .Select(p => p.KnownMoons) .Average() );
public async Task GetClosestPlanetsByStar() { SolarSystemModel solarSystem = await ISolar.GetSolarSystemById(1); ClosestPlanets result = await ISolar.GetClosestPlanetsBySolarSystem(solarSystem); Assert.Equal("earth", result.PlanetA.Name.ToLower()); Assert.Equal("venus", result.PlanetB.Name.ToLower()); }
public IActionResult Get(string name) { SolarSystemModel solarSystem = repo.GetSolarSystemByName(name); if (solarSystem == null) { return(NotFound()); } return(Ok(jconv.Convert(solarSystem))); }
public SolarSystemModel GetSolarSystemByName(string name) { SolarSystemModel solarSystem = db.SolarSystem.FirstOrDefault(s => s.Name.ToUpper().Equals(name.ToUpper())); List <PlanetSolarSystJunction> junctions = db.PlanetSolarSystJunction.Where(ps => ps.SolarSystem.Id == solarSystem.Id).Include("Planet").Include("SolarSystem").ToList(); foreach (PlanetSolarSystJunction ps in junctions) { solarSystem.Planets.Add(ps.Planet); } return(solarSystem); }
public void GetSolarSystem() { Console.WriteLine("Get Solar System Test:"); DomainServiceRepository repo = new DomainServiceRepository(); SolarSystemModel solarSystem = repo.GetSolarSystemByName("The Solar System"); Console.WriteLine("The Solar System Planets: "); foreach (PlanetModel planet in solarSystem.Planets) { Console.WriteLine(planet.Name); } Console.WriteLine(""); }
public SolarSystemModel CreateSolarSystemWithZeroPlanets() { var model = new SolarSystemModel { Name = "Zero planets", TextStyle = { BgrColor = "#002244", FillColor = "#fff", FontSize = 16, FontFamily = "Open Sans" } }; return(model); }
public void LogReader_SystemChanged(object sender, SystemChangedEventArgs e) { var character = CurrentInstance.CharacterList.SingleOrDefault(f => f.CharacterName == e.Listener); if (character == null) { return; } if (character.CurrentSolarSystem.SolarSystemName != e.NewSystemName) { var solarSystem = new SolarSystemModel(); solarSystem.SolarSystemId = e.NewSystemId; solarSystem.SolarSystemName = e.NewSystemName; character.CurrentSolarSystem = solarSystem; } }
public async Task GetByDistanceToSunAscending() { long? lastDistance = null; SolarSystemModel solarSystem = await ISolar.GetSolarSystemById(1); IEnumerable <PlanetAndDwarfPlanet> result = await ISolar.GetByDistanceToSunAscending(solarSystem); foreach (PlanetAndDwarfPlanet planet in result) { if (lastDistance == null) { lastDistance = planet.OrbitDistanceInKM; } else { Assert.True(planet.OrbitDistanceInKM >= lastDistance); lastDistance = planet.OrbitDistanceInKM; } } }
public async Task GetPlanetsByAmountOfMoonsDescending() { int?LastAmountOfMoons = null; SolarSystemModel solarSystem = await ISolar.GetSolarSystemById(1); IEnumerable <PlanetAndDwarfPlanet> result = await ISolar.GetPlanetsByAmountOfMoonsDescending(solarSystem); foreach (PlanetAndDwarfPlanet planet in result) { if (LastAmountOfMoons == null) { LastAmountOfMoons = planet.KnownMoons; } else { Assert.True(planet.KnownMoons <= LastAmountOfMoons); LastAmountOfMoons = planet.KnownMoons; } } }
public async Task GetByNameLenghtascending() { int?LastNameLenght = null; SolarSystemModel solarSystem = await ISolar.GetSolarSystemById(1); IEnumerable <PlanetAndDwarfPlanet> result = await ISolar.GetByNameLenghtAscending(solarSystem); foreach (PlanetAndDwarfPlanet planet in result) { if (LastNameLenght == null) { LastNameLenght = planet.Name.Count(); } else { Assert.True(planet.Name.Count() >= LastNameLenght); LastNameLenght = planet.Name.Count(); } } }
public async Task <ClosestPlanets> GetClosestPlanetsBySolarSystem(SolarSystemModel solarSystem) => await Task.FromResult(context.PlntAndDPlnt .SelectMany(p1 => context.PlntAndDPlnt, (p1, p2) => new { p1, p2 }) .Where(p => p.p1.Id != p.p2.Id) .Select(measure => new { planetA = measure.p1, planetB = measure.p2, measuredDistance = Math.Abs(measure.p1.OrbitDistanceInKM > measure.p2.OrbitDistanceInKM ? measure.p1.OrbitDistanceInKM - measure.p2.OrbitDistanceInKM : measure.p2.OrbitDistanceInKM - measure.p1.OrbitDistanceInKM) }) .OrderBy(d => d.measuredDistance) .Select(res => new ClosestPlanets() { PlanetA = res.planetA, PlanetB = res.planetB, Distance = res.measuredDistance }) .First());
public static void MainMenuComp(string LetterString, SolarSystemModel ChosenSolarSystem) { switch (LetterString.ToLower()) { case "planeten": PlanetRenderer.PlanetPageRendering(ChosenSolarSystem); break; case "q": Environment.Exit(0); break; case "quit": Environment.Exit(0); break; default: Console.WriteLine("The chosen command was not recognized! please try again."); break; } }
static async Task Main(string[] args) { (int, string)result = (0, null); string input = null; string LetterString = null; SolarSystemModel ChosenSolarSystem = null; int Numbers = 0; bool running = true; while (running) { result = await InputUiParts.GetInputAndParse(input); Numbers = result.Item1; LetterString = result.Item2; while (ChosenSolarSystem == null) { result = await InputUiParts.GetInputAndParse(input); ChosenSolarSystem = await SolarSystemUIComponents.SetChosenSolarSystem(result); } if (ChosenSolarSystem != null) { result = await InputUiParts.GetInputAndParse(input); Numbers = result.Item1; LetterString = result.Item2; } if (LetterString != null) { if (ChosenSolarSystem != null) { InputUiParts.MainMenuComp(LetterString, ChosenSolarSystem); } } } }
public static async void PlanetPageRendering(SolarSystemModel ChosenSolarSystem) { string input = null; string LetterString = null; string NumberString = null; long Numbers; while (true) { (int, string)result = await InputUiParts.GetInputAndParse(input); Numbers = result.Item1; LetterString = result.Item2; if (LetterString != null) { if (LetterString == "q") { Environment.Exit(0); } } } }
public async Task <int> TotalAmountOfMoons(SolarSystemModel solarSystem) => await Task.FromResult(context.PlntAndDPlnt.Where(p => p.SolarSystemToOrbit == solarSystem) .Select(p => p.KnownMoons).Sum());
public async Task <(double, double, double)> PrintListOfAvgTempsForTypesBySolarSystem(SolarSystemModel solarSystem) =>
public void Reset() { _model = new SolarSystemModel(); }
public async Task <IEnumerable <PlanetAndDwarfPlanet> > GetByNameLenghtAscending(SolarSystemModel solarSystem) => await Task.FromResult(context.PlntAndDPlnt.Where(p => p.SolarSystemToOrbit == solarSystem) .OrderBy(p => p.Name.Length));
public SolarSystemModel CreateLargeSolarSystem() { var model = new SolarSystemModel { Name = "Large Solar System", TextStyle = { BgrColor = "#002244", FillColor = "#fff", FontSize = 16, FontFamily = "Open Sans" } }; model.Planets.Add(new Planet { Name = "Selene", OrbitRadius = 90, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 20000 }); model.Planets.Add(new Planet { Name = "Mimas", OrbitRadius = 116, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 20000 }); model.Planets.Add(new Planet { Name = "Ares", OrbitRadius = 142, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 20000 }); model.Planets.Add(new Planet { Name = "Enceladus", OrbitRadius = 168, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 23000 }); model.Planets.Add(new Planet { Name = "Tethys", OrbitRadius = 194, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 14000 }); model.Planets.Add(new Planet { Name = "Dione", OrbitRadius = 220, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 10000 }); model.Planets.Add(new Planet { Name = "Zeus", OrbitRadius = 246, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 53000 }); model.Planets.Add(new Planet { Name = "Rhea", OrbitRadius = 272, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 15000 }); model.Planets.Add(new Planet { Name = "Titan", OrbitRadius = 298, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 30000 }); model.Planets.Add(new Planet { Name = "Hyperion", OrbitRadius = 324, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 28000 }); model.Planets.Add(new Planet { Name = "Iapetus", OrbitRadius = 350, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 22000 }); model.Planets.Add(new Planet { Name = "Janus", OrbitRadius = 376, OrbitStroke = "rgb(1, 192, 255, 0.5)", RotationDuration = 24000 }); return(model); }
public async Task <IEnumerable <PlanetAndDwarfPlanet> > GetPlanetsBySolarSystem(SolarSystemModel solarSystem) => await Task.FromResult(context.PlntAndDPlnt.Where(p => p.SolarSystemId == solarSystem.Id));
public async Task <IEnumerable <PlanetAndDwarfPlanet> > GetPlanetsByAmountOfMoonsDescending(SolarSystemModel solarSystem) => await Task.FromResult(context.PlntAndDPlnt.Where(p => p.SolarSystemToOrbit == solarSystem) .OrderByDescending(p => p.KnownMoons));
public async Task <IEnumerable <StarModel> > GetStarsBySolarSystem(SolarSystemModel solarSystem) => await Task.FromResult( context.Stars.Where(s => s.SolarSystemId == solarSystem.Id));
public static void Seed(this ModelBuilder modelBuilder) { ICollection <StarModel> starlist = new List <StarModel>(); ICollection <PlanetAndDwarfPlanet> planetlist = new List <PlanetAndDwarfPlanet>(); var TheSun = new StarModel { Id = 1, Name = "The Sun", DiameterInKM = 1392694, SurfaceTempMax = 5500, SurfaceTempMin = 5500, Age = 4600000000, CoreTemp = 15000000, SolarSystemId = 1 }; starlist.Add(TheSun); var Mercury = new PlanetAndDwarfPlanet { Id = 1, Name = "Mercury", DiameterInKM = 4879, SurfaceTempMax = -173, SurfaceTempMin = -427, KnownMoons = 0, OrbitDistanceInKM = 57900000, OrbitPeriodInDays = 88, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Mercury); var Venus = new PlanetAndDwarfPlanet { Id = 2, Name = "Venus", DiameterInKM = 12104, SurfaceTempMax = 462, SurfaceTempMin = 462, KnownMoons = 0, OrbitDistanceInKM = 108200000, OrbitPeriodInDays = 224.7, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Venus); var Earth = new PlanetAndDwarfPlanet { Id = 3, Name = "Earth", DiameterInKM = 12756, SurfaceTempMax = 58, SurfaceTempMin = -88, KnownMoons = 1, OrbitDistanceInKM = 149600000, OrbitPeriodInDays = 365.2, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Earth); var Mars = new PlanetAndDwarfPlanet { Id = 4, Name = "Mars", DiameterInKM = 6805, SurfaceTempMax = -63, SurfaceTempMin = -63, KnownMoons = 2, OrbitDistanceInKM = 227900000, OrbitPeriodInDays = 693.96, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Mars); var Ceres = new PlanetAndDwarfPlanet { Id = 5, Name = "Ceres", DiameterInKM = 950, SurfaceTempMax = -105, SurfaceTempMin = -105, KnownMoons = 0, OrbitDistanceInKM = 413700000, OrbitPeriodInDays = 1680.11, Type = CelestialTypeEnum.DwarfPlanet, SolarSystemId = 1 }; planetlist.Add(Ceres); var Jupiter = new PlanetAndDwarfPlanet { Id = 6, Name = "Jupiter", DiameterInKM = 142984, SurfaceTempMax = -108, SurfaceTempMin = -108, KnownMoons = 67, OrbitDistanceInKM = 778300000, OrbitPeriodInDays = 4346.38, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Jupiter); var Saturn = new PlanetAndDwarfPlanet { Id = 7, Name = "Saturn", DiameterInKM = 120536, SurfaceTempMax = -139, SurfaceTempMin = -139, KnownMoons = 62, OrbitDistanceInKM = 1400000000, OrbitPeriodInDays = 10774.65, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Saturn); var Uranus = new PlanetAndDwarfPlanet { Id = 8, Name = "Uranus", DiameterInKM = 51118, SurfaceTempMax = -197, SurfaceTempMin = -197, KnownMoons = 27, OrbitDistanceInKM = 2900000000, OrbitPeriodInDays = 30680.37, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Uranus); var Neptune = new PlanetAndDwarfPlanet { Id = 9, Name = "Neptune", DiameterInKM = 49528, SurfaceTempMax = -201, SurfaceTempMin = -201, KnownMoons = 14, OrbitDistanceInKM = 4500000000, OrbitPeriodInDays = 60191.96, Type = CelestialTypeEnum.Planet, SolarSystemId = 1 }; planetlist.Add(Neptune); var Pluto = new PlanetAndDwarfPlanet { Id = 10, Name = "Pluto", DiameterInKM = 2306, SurfaceTempMax = -229, SurfaceTempMin = -229, KnownMoons = 5, OrbitDistanceInKM = 5900000000, OrbitPeriodInDays = 89849.65, Type = CelestialTypeEnum.DwarfPlanet, SolarSystemId = 1 }; planetlist.Add(Pluto); var Haumea = new PlanetAndDwarfPlanet { Id = 11, Name = "Haumea", DiameterInKM = 1739, SurfaceTempMax = -241, SurfaceTempMin = -241, KnownMoons = 2, OrbitDistanceInKM = 6400000000, OrbitPeriodInDays = 103473.20, Type = CelestialTypeEnum.DwarfPlanet, SolarSystemId = 1 }; planetlist.Add(Haumea); var Makemake = new PlanetAndDwarfPlanet { Id = 12, Name = "Makemake", DiameterInKM = 1434, SurfaceTempMax = -241, SurfaceTempMin = -241, KnownMoons = 0, OrbitDistanceInKM = 6900000000, OrbitPeriodInDays = 113188.65, Type = CelestialTypeEnum.DwarfPlanet, SolarSystemId = 1 }; planetlist.Add(Makemake); var Eris = new PlanetAndDwarfPlanet { Id = 13, Name = "Eris", DiameterInKM = 1434, SurfaceTempMax = -241, SurfaceTempMin = -241, KnownMoons = 1, OrbitDistanceInKM = 10100000000, OrbitPeriodInDays = 204864.52, Type = CelestialTypeEnum.DwarfPlanet, SolarSystemId = 1 }; planetlist.Add(Eris); var TheSolarSystem = new SolarSystemModel { Id = 1, Name = "The Solar system", }; modelBuilder.Entity <StarModel>().HasData(TheSun); foreach (PlanetAndDwarfPlanet planet in planetlist) { modelBuilder.Entity <PlanetAndDwarfPlanet>().HasData(planet); } modelBuilder.Entity <SolarSystemModel>().HasData(TheSolarSystem); }
public async Task <int> GetTotalAmountOfBodies(SolarSystemModel solarSystem) => await GetPlanetCountBySolarSystem(solarSystem) + await GetStarCountBySolarSystem(solarSystem) + await GetKnownMoonsCountBySolarSystem(solarSystem);
public string Convert(SolarSystemModel solarSystem) { return(JsonConvert.SerializeObject(solarSystem)); }
public async Task <IEnumerable <PlanetAndDwarfPlanet> > GetByDistanceToSunAscending(SolarSystemModel solarSystem) => await Task.FromResult(context.PlntAndDPlnt.Where(p => p.SolarSystemToOrbit == solarSystem) .OrderBy(p => p.OrbitDistanceInKM));