示例#1
0
 public void Import()
 {
     InitContext();
     FullLogBookInitNew.S0_ConvertCustomPropertyTypes(_context);
     FullLogBookInitNew.S01_ConvertFromMyflightBookAirplane(_context);
     FullLogBookInitNew.S2_CreateClubGeneral(_context, "4XCGC", "BAZ", SupportedClub.BAZ);
     //FullLogBookInitNew.S2_CreateClubGeneral(_context, "4XCGC", "BAZ1", SupportedClub.BAZ1);
     FullLogBookInitNew.S3_CreateLogBook(_context, "059828392");
     FullLogBookInitNew.S4_ConvertFromMyflightBookFlightCSV(_context, "059828392");
     FullLogBookInitNew.s5_ConverBuzClubAirplaneFlight(_context);
 }
        public static int SeedDatabase(this ApplicationDbContext db, string dataDirectory, bool createNew = false)
        {
            if (!(db.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
            {
                throw new InvalidAsynchronousStateException("the database does not exist. If you are using Migration then Run PMC command update-database to create it");
            }


            if (db.CustomPropertyTypes.Count() == 0)
            {
                // FullLogBookInitNew.S0_ConvertCustomPropertyTypes(db);
            }
            if (db.AirCraftModels.Any() == false)
            {
                //FullLogBookInitNew.S01_ConvertFromMyflightBookAirplane(db);
            }
            if (db.Clubs.Count() == 0)
            {
                FullLogBookInitNew.S2_CreateClubGeneral(db, "4XCGC", "BAZ", SupportedClub.BOTH);
            }

            /*
             * if(FullLogBookInitNew.S3_CreateLogBook(db, 059828392))
             * {
             *  FullLogBookInitNew.S4_ConvertFromMyflightBookFlightCSV(db, 059828392);
             * }
             */
            //FullLogBookInitNew.s5_ConverBuzClubAirplaneFlight(db);
            if (createNew)
            {
                FullLogBookInitNew.UpdatePilotDefaultPhoto(db);
                FullLogBookInitNew.UpdateairplaneDefaultPhoto(db);
                return(0);
            }
            //var numPilots = db.Pilots.Count();
            //if (numPilots == 0)
            //{
            //             //Code to fill data base data
            //             FullLogBookInitNew.ConvertLogBook(db);
            //}
            return(0);
        }