private void LoadEvaluations()
        {
            //            For testing
            //var x = SqLiteConnection.DropTable<Evaluation>();
            //x = SqLiteConnection.DropTable<Option>();
            //x = SqLiteConnection.DropTable<CriteriaOption>();
            //x = SqLiteConnection.DropTable<Criteria>();

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try {
                Evaluations = new ObservableRangeCollection <Evaluation>(SqLiteConnection.GetAllWithChildren <Evaluation>());
            } catch (Exception ex) {
                if (ex.Message == "no such table: Evaluation" || ex.Message == "no such table: Criteria" || ex.Message == "no such table: Option" || ex.Message == "no such table: CriteriaOption")
                {
                    SqLiteConnection.CreateTable <Criteria>();
                    SqLiteConnection.CreateTable <Option>();
                    SqLiteConnection.CreateTable <Evaluation>();
                    SqLiteConnection.CreateTable <CriteriaOption>();
                    Evaluations = new ObservableRangeCollection <Evaluation>(SqLiteConnection.Table <Evaluation>().ToList());
                }
            } finally {
                IsBusy = false;
            }
        }
Beispiel #2
0
        private DatabaseManager()
        {
            string fileName = Path.Combine(PathController.Instance.Path, "settigs.db");
            _database = new SqLiteConnection(fileName);
            //_database.DropTable<Game>();
            _database.CreateTable<Game>();

            var count = _database.Table<Game>().ToList();
        }
 /// <summary>
 /// Saves Options locally and popasync
 /// </summary>
 private async Task SaveClickedAsync()
 {
     if (Option != null)
     {
         try {
             SqLiteConnection.Insert(Option);
         } catch (Exception e) {
             if (e.Message == "no such table: Option")
             {
                 SqLiteConnection.CreateTable <Option>();
                 SqLiteConnection.Insert(Option);
             }
         } finally {
             MessagingCenter.Send <NewOptionViewModel, Option>(this, "AddOptionM", Option);
             var page = Application.Current.MainPage as TabbedPage;
             await page.Children[1].Navigation.PopAsync();
         }
     }
 }
 /// <summary>
 /// Save Criteria locally and popAsync
 /// </summary>
 private async Task SaveClickedAsync()
 {
     if (Criteria != null)
     {
         try {
             SqLiteConnection.InsertWithChildren(Criteria);
         } catch (SQLite.SQLiteException e) {
             if (e.Message == "no such table: Criteria")
             {
                 SqLiteConnection.CreateTable <Criteria>();
                 SqLiteConnection.Insert(Criteria);
             }
         } finally {
             SqLiteConnection.InsertWithChildren(Criteria);
             MessagingCenter.Send <NewCriteriaViewModel, Criteria>(this, "AddCriteriaM", Criteria);
             var page = Application.Current.MainPage as TabbedPage;
             await page.Children[2].Navigation.PopAsync();
         }
     }
 }
Beispiel #5
0
        private async Task SaveClickedAsync()
        {
            if (Evaluation != null)
            {
                Evaluation.Criterias = new List <Criteria>();
                Evaluation.Options   = new List <Option>();

                try {
                    SqLiteConnection.Insert(Evaluation);
                } catch (Exception e) {
                    if (e.Message == "no such table: Evaluation")
                    {
                        SqLiteConnection.CreateTable <Evaluation>();
                        SqLiteConnection.Insert(Evaluation);
                    }
                } finally {
                    MessagingCenter.Send <NewEvaluationViewModel>(this, "AddEvaluationM");
                    var            page    = Application.Current.MainPage as TabbedPage;
                    NavigationPage navPage = page.Children[0] as NavigationPage;
                    await navPage.Navigation.PopAsync();
                }
            }
        }