public async Task <Set> GetSet(long id) { var local = await _setsLocalStorage.GetSetById(id); if (local != null) { if (local.Terms == null) { Set remoteSet = null; if (SetIsPrivate(local.Visibility)) { remoteSet = await _quizletRESTApi.GetPrivateSet(local.Id); } else { remoteSet = await _quizletRESTApi.GetPublicSet(local.Id); } } return(local); } else { var remoteSet = await _quizletRESTApi.GetPublicSet(id); return(remoteSet); } }
public async void SubmitClicked(object sender, RoutedEventArgs e) { var tempDialog = new MessageDialog("Sorry, this feature isn't available yet due to Quizlet API limitations"); await tempDialog.ShowAsync(); return; //todo: get scope from Quizlet to allow this... if (string.IsNullOrEmpty(Password)) { var dialog = new MessageDialog("Please type in a password."); await dialog.ShowAsync(); } else { var result = await _quizApi.GetPrivateSet(SetId, Password); if (result) { var set = _quizApi.GetPublicSet(SetId); } else { Password = string.Empty; } } }
public async Task ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { var setVm = (SetViewModel)((ListView)sender).SelectedItem; try { Views.Busy.SetBusy(true, _loader.GetString("HttpLoading")); var set = await _quizApi.GetPublicSet(setVm.Id); Views.Busy.SetBusy(false, null); NavigationService.Navigate(typeof(Views.SetDetailPage), set); } catch (SetIsPrivateException) { // handle password protected case. Views.Busy.SetBusy(false, null); NavigationService.Navigate(typeof(Views.PrivateSetPage), setVm); } catch (Exception k) { Views.Busy.SetBusy(false, null); var dialog = new MessageDialog($"Error: {k.Message}"); await dialog.ShowAsync(); return; } }
public async Task Selected(object sender, SelectionChangedEventArgs e) { var session = (StudySessionViewModel)((ListView)sender).SelectedItem; Views.Busy.SetBusy(true, _loader.GetString("HttpLoading")); var set = await _quizApi.GetPublicSet(session.Id); Views.Busy.SetBusy(false, null); NavigationService.Navigate(typeof(Views.SetDetailPage), set); }
public async Task SelectedSet(object sender, SelectionChangedEventArgs e) { var set = (SetQViewModel)((ListView)sender).SelectedItem; Views.Busy.SetBusy(true, _loader.GetString("HttpLoading")); var fecthedSet = await _remoteApi.GetPublicSet(set.Id); Views.Busy.SetBusy(false, null); PivotNavIndex = 0; NavigationService.Navigate(typeof(Views.SetDetailPage), fecthedSet); }
private async Task UpdateSets() { try { if (_settingsService.AuthenticatedUser != null) { var remoteSets = await _quizApi.GetCreatedSets(); var sets = new List <Set>(); foreach (var set in remoteSets.Items) { Set remoteSet = null; if (SetIsPrivate(set.ItemData.Visibility)) { remoteSet = await _quizApi.GetPrivateSet(set.ItemData.Id); } else { remoteSet = await _quizApi.GetPublicSet(set.ItemData.Id); } sets.Add(remoteSet); await _setStorage.AddSet(remoteSet); } await _setStorage.SaveSets(); if (sets.Any()) { Sets.Clear(); ContainsData = true; ShowNothingHere = false; foreach (var set in sets) { Sets.Add(new SetViewModel(set)); } } } } catch (Exception e) { var dialog = new MessageDialog($"Error: {e.Message}"); await dialog.ShowAsync(); return; } }