示例#1
0
        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();
                }
            }
        }
示例#2
0
        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));
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
 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;
             }
         }
     }
 }
示例#5
0
        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);
                }
            }
        }
示例#6
0
        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));
                    }
                }
            }
        }
示例#7
0
        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);
            }
        }