private async void HandleConfirmMessage(bool shouldBeRemoved) { if (shouldBeRemoved) { if (await CheckInternetConnection()) { IsDataLoading = true; try { bool success = await _restService.RemoveDeck(_selectedID); if (success) { DecksCollection.Remove(DecksCollection.Where(x => x.ID == _selectedID).First()); } } catch { } IsDataLoading = false; if (DecksCollection != null && DecksCollection.Count == 0) { IsNoDecks = true; } BackToDeck(); } } }
private async void GoToLearning() { if (await CheckInternetConnection()) { IsDeckSelected = false; NavigationService.NavigateTo("LearningView"); Deck deck = DecksCollection.Where(x => x.ID == _selectedID).FirstOrDefault(); _selectedID = String.Empty; Messenger.Default.Send <DataMessageToExam>(new DataMessageToExam(deck)); Messenger.Default.Send <MessageToMenuControl>(new MessageToMenuControl(false, false, deck.Name)); } }
private async void GoToTest() { if (await CheckInternetConnection()) { IsDeckSelected = false; NavigationService.NavigateTo("ExamView"); Deck deck = DecksCollection.Where(x => x.ID == _selectedID).FirstOrDefault(); _selectedID = String.Empty; Messenger.Default.Send <DataMessageToExam>(new DataMessageToExam(deck)); Messenger.Default.Send <MessageToMenuControl>(new MessageToMenuControl(false, false, deck.Name)); _statisticsService.IncrementTestsCountAnswers(); _statisticsService.IncrementCountOfDecks(deck); } }
private void CheckIfDeckIsFavourite() { if (_favouriteDecks != null) { foreach (Deck deck in _favouriteDecks) { Deck favouriteDeck = DecksCollection.Where(x => x.ID == deck.ID).FirstOrDefault(); if (favouriteDeck != null) { favouriteDeck.ViewModel.IsFavourite = true; favouriteDeck.ViewModel.AddToFavouriteDecksDate = deck.ViewModel.AddToFavouriteDecksDate; } } } }
private void RemoveFromFavourite(string id) { if (IsUser) { Deck deck = DecksCollection.Where(x => x.ID == id).FirstOrDefault(); if (deck.ViewModel == null) { deck.ViewModel = new DeckViewModel(); } deck.ViewModel.IsFavourite = false; deck.ViewModel.AddToFavouriteDecksDate = default(DateTime); if (_favouriteDecks != null) { Deck deckToRemove = _favouriteDecks.Where(x => x.ID == id).FirstOrDefault(); _favouriteDecks.Remove(deckToRemove); _favouriteService.SaveFavouriteDecks(_favouriteDecks); } } }
private async void TapTile(string id) { Messenger.Default.Send <MessageToMessageBoxControl>(new MessageToMessageBoxControl(false)); if (await CheckInternetConnection()) { _selectedID = id; IsDeckSelected = true; IsMyDeck = false; string name = DecksCollection.Where(x => x.ID == _selectedID).FirstOrDefault().Name; Messenger.Default.Send <MessageToMenuControl>(new MessageToMenuControl(false, false, name)); if (_decksType == DecksType.MyDecks) { IsMyDeck = true; } else { try { Deck deck = await _restService.GetDeckById(_selectedID); if (deck != null) { if (_accountService.IsUserLoggedIn()) { if (_accountService.GetUserEmail() == deck.CreatorEmail) { IsMyDeck = true; } } } } catch (Exception ex) { Messenger.Default.Send <MessageToMessageBoxControl>(new MessageToMessageBoxControl(true, false, true, false, ex.Message)); } } } }
private void AddToFavourite(string id) { if (IsUser) { Deck deck = DecksCollection.Where(x => x.ID == id).FirstOrDefault(); if (deck.ViewModel == null) { deck.ViewModel = new DeckViewModel(); } deck.ViewModel.IsFavourite = true; deck.ViewModel.AddToFavouriteDecksDate = DateTime.Now; if (_favouriteDecks == null) { _favouriteDecks = new List <Deck>(); } _favouriteDecks.Add(deck); _favouriteService.SaveFavouriteDecks(_favouriteDecks); } }