Пример #1
0
        private static void ImportPlanets()
        {
            string jsonFile = File.ReadAllText("../../../Resources/planets.json");
            var    planets  = JsonConvert.DeserializeObject <IEnumerable <PlanetDto> >(jsonFile);

            foreach (var planetDto in planets)
            {
                if (planetDto.Name == null ||
                    planetDto.StarSystem == null ||
                    planetDto.Mass <= 0 ||
                    planetDto.Mass == null)
                {
                    Printer.PrintError();
                    continue;
                }
                QueryMethods.AddPlanet(planetDto);
            }
        }