public static void ImportAstronomers(ICollection <AstronomerDTO> astronomers)
        {
            using (var context = new PlanetHuntersContext())
            {
                foreach (var astronomer in astronomers)
                {
                    if (astronomer.FirstName == null || astronomer.LastName == null)
                    {
                        Console.WriteLine("Invalid data format.");
                        continue;
                    }

                    Astronomer astronomerEntity = new Astronomer()
                    {
                        FirstName = astronomer.FirstName,
                        LastName  = astronomer.LastName
                    };

                    context.Astronomers.Add(astronomerEntity);
                    Console.WriteLine($"Successfully imported {nameof(astronomerEntity)} {astronomerEntity.FirstName}.");
                }

                context.SaveChanges();
            }
        }
        public static bool IsAstronomerExisting(PlanetHuntersContext context, string firstName, string lastName)
        {
            Astronomer astronomerEntity = context.Astronomers
                                          .FirstOrDefault(astronomer => astronomer.FirstName == firstName && astronomer.LastName == lastName);

            if (astronomerEntity == null)
            {
                return(false);
            }

            return(true);
        }
 public static void AddAstronomerToDatabase(PlanetHuntersContext context, Astronomer astronomerEntity)
 {
     try
     {
         context.Astronomers.Add(astronomerEntity);
         context.SaveChanges();
         Console.WriteLine(Messages.AstronomerImported, astronomerEntity.FirstName, astronomerEntity.LastName);
     }
     catch (DbEntityValidationException)
     {
         context.Astronomers.Remove(astronomerEntity);
         Console.WriteLine(Messages.Error);
     }
 }