Beispiel #1
0
        private async Task OnDeleteFavorite()
        {
            if (SelectedFavorites?.Count > 0)
            {
                bool canNavigate = await NavigationManager.CanPopUpNavigateAsync <ChoiceModalViewModel>();

                if (canNavigate)
                {
                    var actors = SelectedFavorites.Cast <FavoritedVoiceActor>().ToList();
                    var action = new Action(() =>
                    {
                        var voiceActorCollection = App.liteDB.GetCollection <FavoritedVoiceActor>();
                        foreach (var item in actors)
                        {
                            voiceActorCollection.Delete(item.VoiceActor.MalId);
                        }

                        FavoritedActors.RemoveRange(actors);
                    });

                    await NavigationManager.NavigatePopUpAsync <ChoiceModalViewModel>(Lang.Lang.ClearFavoriteList, Lang.Lang.ClearCannotBeUndone, action);

                    SelectedFavorites = null;
                }
            }
        }
Beispiel #2
0
        private async Task OnSearch()
        {
            var resultListTask = Task.Run(() =>
            {
                return(_originalCollection.Where(actor => actor.VoiceActor.Name.ToLowerInvariant().Contains(SearchQuery.ToLowerInvariant())).ToList());
            });

            var resultList = await resultListTask;

            FavoritedActors.ReplaceRange(resultList);
        }
Beispiel #3
0
        public async Task LoadAsync()
        {
            await Task.Run(() =>
            {
                if (_isUpdatingVoiceActors)
                {
                    return;
                }

                FavoritedActors.ReplaceRange(App.liteDB.GetCollection <FavoritedVoiceActor>().FindAll().ToList());
                _originalCollection = new List <FavoritedVoiceActor>(FavoritedActors);
            });
        }
Beispiel #4
0
        private async Task OnClearAllRecent()
        {
            if (FavoritedActors.Count == 0)
            {
                return;
            }

            bool canNavigate = await NavigationManager.CanPopUpNavigateAsync <ChoiceModalViewModel>();

            if (canNavigate)
            {
                var confirmDelegateAction = new Action(() =>
                {
                    App.liteDB.GetCollection <FavoritedVoiceActor>().DeleteAll();
                    FavoritedActors.Clear();
                });

                await NavigationManager.
                NavigatePopUpAsync <ChoiceModalViewModel>(Lang.Lang.ClearFavoriteList, Lang.Lang.ClearCannotBeUndone, confirmDelegateAction);
            }
        }