/// <summary>
        /// Creates a new category.
        /// </summary>
        /// <param name="categoryName">The category name.</param>
        /// <returns>The category.</returns>
        public async Task <Category> CreateCategory(string categoryName)
        {
            await SimulateWaitAndError();

            var categoryPreview = new CategoryPreview
            {
                Id              = Guid.NewGuid().ToString(),
                Name            = categoryName,
                PhotoThumbnails = new List <PhotoThumbnail>()
            };

            TopCategories.Add(categoryPreview);

            return(categoryPreview.ToCategory());
        }
        /// <summary>
        /// Loads the state.
        /// </summary>
        public override async Task LoadState()
        {
            await base.LoadState();

            IsBusy = true;
            IsStatusContainerVisible = true;

            try
            {
                TopCategories.Clear();

                // Load hero images
                //var heroImages = await _petCareService.GetHeroImages(NumberOfHeroImages);
                TopImages.Clear();
                //heroImages.ForEach(h => HeroImages.Add(h));


                // Load categories
                InitializeCategoryItems().Wait();
                var categories =
                    AccessoryCombinations;

                IsEmptyDataMessageVisible = !categories.Any();
                IsStatusContainerVisible  = !categories.Any();

                for (int i = 0; i < 4; i++)
                {
                    TopImages.Add(categories[0].ListOfAccessory[i]);
                }

                foreach (var c in categories)
                {
                    TopCategories.Add(c);

                    // For UI animation purposes, we wait a little until the next
                    // element is inserted.
                    await Task.Delay(200);
                }
            }
            catch (ServiceException)
            {
                await _dialogService.ShowGenericServiceErrorNotification();
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Loads the state.
        /// </summary>
        public override async Task LoadState()
        {
            await base.LoadState();

            IsBusy = true;
            IsStatusContainerVisible = true;

            try
            {
                TopCategories.Clear();

                // Load hero images
                var heroImages = await _photoService.GetHeroImages(NumberOfHeroImages);

                HeroImages.Clear();
                heroImages.ForEach(h => HeroImages.Add(h));

                // Load categories
                var categories =
                    await _photoService.GetTopCategories(AppEnvironment.Instance.CategoryThumbnailsCount);

                IsEmptyDataMessageVisible = !categories.Any();
                IsStatusContainerVisible  = !categories.Any();

                foreach (var c in categories)
                {
                    TopCategories.Add(c);

                    // For UI animation purposes, we wait a little until the next
                    // element is inserted.
                    await Task.Delay(200);
                }
            }
            catch (ServiceException)
            {
                await _dialogService.ShowGenericServiceErrorNotification();
            }
            finally
            {
                IsBusy = false;
            }
        }