Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            // drop tables to test
            // await this.sqliteData.DropTableAsync<UserProfile>();
            // await this.sqliteData.DropTableAsync<Skill>();

            // Create Db if not exist

            bool dbExists = await sqliteData.CheckDbAsync(GlobalConstants.DbName);

            if (!dbExists)
            {
                await sqliteData.CreateDatabaseAsync <SkillSummary>();

                await sqliteData.CreateDatabaseAsync <UserProfile>();

                //await sqliteData.CreateDatabaseAsync<Answer>();
                //await sqliteData.CreateDatabaseAsync<Question>();
                //await sqliteData.CreateDatabaseAsync<TrainingSession>();

                await dataSeeder.SeedUserProfile();

                //await dataSeeder.SeedSkills();
            }

            // test - get user profile TODO: remove

            //SQLiteAsyncConnection conn = new SQLiteAsyncConnection(GlobalConstants.DbName);
            //var queryProfiles = conn.Table<UserProfile>();
            //var userProfiles = await queryProfiles.ToListAsync();

            //var querySkills = conn.Table<Skill>();
            //var skills = await querySkills.ToListAsync();

            // show user
            //this.DataContext = userProfiles.FirstOrDefault();

            this.RegisterBackgroundTask();
        }