Пример #1
0
        async Task <bool> ExecuteLoadWorkshopsAsync(bool force = false)
        {
            if (IsBusy)
            {
                return(false);
            }

            try
            {
                NextForceRefresh = DateTime.UtcNow.AddMinutes(45);
                IsBusy           = true;
                NoWorkshopsFound = false;
                Filter           = string.Empty;

                Workshops.ReplaceRange((await StoreManager.WorkshopStore.GetItemsAsync(force)).ToWorkshopCellViews(WorkshopCellViewModelFactory));

                WorkshopsFiltered.ReplaceRange(Workshops.Search());
                SortWorkshops();

                if (WorkshopsGrouped.Count == 0)
                {
                    if (Settings.FavoritesOnly)
                    {
                        if (!Settings.ShowPastWorkshops)
                        {
                            NoWorkshopsFoundMessage = "You haven't favorited\nany workshops yet.";
                        }
                        else
                        {
                            NoWorkshopsFoundMessage = "No Workshops Found";
                        }
                    }
                    else
                    {
                        NoWorkshopsFoundMessage = "No Workshops Found";
                    }

                    NoWorkshopsFound = true;
                }
                else
                {
                    NoWorkshopsFound = false;
                }
            }
            catch (Exception ex)
            {
                Logger.Log($"{ex.Message}, Method, ExecuteLoadWorkshopsAsync", Prism.Logging.Category.Exception, Priority.High);
                EventAggregator.GetEvent <ErrorEvent>().Publish(ex);
            }
            finally
            {
                IsBusy = false;
            }

            return(true);
        }
Пример #2
0
        async Task ExecuteFilterWorkshopsAsync()
        {
            IsBusy           = true;
            NoWorkshopsFound = false;

            // Abort the current command if the query has changed and is not empty
            if (!string.IsNullOrEmpty(Filter))
            {
                var query = Filter;
                await Task.Delay(250);

                if (query != Filter)
                {
                    return;
                }
            }

            WorkshopsFiltered.ReplaceRange(Workshops.Search(Filter));
            SortWorkshops();

            if (WorkshopsGrouped.Count == 0)
            {
                if (Settings.FavoritesOnly)
                {
                    if (!Settings.ShowPastWorkshops && !string.IsNullOrWhiteSpace(Filter))
                    {
                        NoWorkshopsFoundMessage = "You haven't favorited\nany workshops yet.";
                    }
                    else
                    {
                        NoWorkshopsFoundMessage = "No Workshops Found";
                    }
                }
                else
                {
                    NoWorkshopsFoundMessage = "No Workshops Found";
                }

                NoWorkshopsFound = true;
            }
            else
            {
                NoWorkshopsFound = false;
            }

            IsBusy = false;
        }