private void ListenToInternetConnection() { // initial verif offline.Visibility = (Network.IsConnected ? Visibility.Collapsed : Visibility.Visible); Network.InternetConnectionChanged += async(s, e) => { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { offline.Visibility = (e.IsConnected ? Visibility.Collapsed : Visibility.Visible); if (e.IsConnected) { using (var db = new SurveyContext()) { if (db.Surveys.ToList().Count != 0 && !db.GetSurvey().WasSent) { SendToEtouchesAPI(db.GetSurvey()); db.DeleteCache(); await Popup_OnlineMode(); } } } }); }; }
private async void ShowDatabase(object sender, RoutedEventArgs e) { using (var db = new SurveyContext()) { string text = ""; if (!db.IsEmpty()) { Survey survey = db.GetSurvey(); text += "SurveyId = " + survey.SurveyId + " Title = " + survey.Title + " WasSent? " + survey.WasSent + "\n"; foreach (Question q in db.Questions.ToList()) { text += "Question: " + q.Text + " Type = " + q.Type + " Answer = " + q.Answer + "\n"; } } else { text += "The database is empty! No survey is cached."; } var message = new Windows.UI.Popups.MessageDialog("Hello!\n" + text); message.Title = "The db was imported!"; message.Commands.Add(new Windows.UI.Popups.UICommand("Cancel") { Id = 0 }); await message.ShowAsync(); } }
private void AddToLocalStorage(Survey survey) { using (var db = new SurveyContext()) { db.AddSurvey(survey); } }
private void UpdateSurveyStatus(Survey survey) { survey.WasSent = true; using (var db = new SurveyContext()) { db.UpdateSurveyStatus(survey.SurveyId, survey.WasSent); } }