public CatalogListPage(string OfferCode)
 {
     InitializeComponent();
     vm              = new CatalogPageViewModel(OfferCode);
     BindingContext  = vm;
     visualContainer = ListViewList.GetVisualContainer();
     visualContainer.ScrollRows.Changed += ScrollRows_Changed;
 }
        public void OneMovieIsFiltered()
        {
            var viewModel = new CatalogPageViewModel(null, movieRepository);

            viewModel.Genres[0].IsSelected = true;

            Assert.AreEqual(viewModel.Movies.Count, 1);
            Assert.AreEqual(viewModel.Movies[0].Title, "Action Movie");
        }
Exemple #3
0
        public async Task <CatalogPageViewModel> SearchProductByCategoryAsync(long categoryId, PagingOptions pagingOptions)
        {
            var category = await _catalogApi.GetCategoryAsync(_catalogApi.GetCategoryUri(categoryId)).ConfigureAwait(false);

            var categoryViewModel = CreateCategoryViewModel(category, categoryId);

            if (pagingOptions == null)
            {
                pagingOptions = new PagingOptions();
            }

            if (categoryViewModel == null)
            {
                var viewModel = new CatalogPageViewModel
                {
                    CategoryId = categoryId,
                    Products   = new Products {
                        Product = new Product[0]
                    }
                };
                viewModel.SetPageTitle("Catalog");
                return(viewModel);
            }

            Products searchResult;

            try
            {
                searchResult = await _catalogApi.GetProductsForCategoryAsync(category, pagingOptions).ConfigureAwait(false);
            }
            catch (Exception)
            {
                searchResult = new Products {
                    Product = new Product[0]
                };
            }

            var viewMod = new CatalogPageViewModel
            {
                Title              = categoryViewModel.DisplayName,
                CategoryId         = categoryId,
                Products           = searchResult,
                KeyWords           = categoryViewModel.Keywords,
                TotalPages         = searchResult.TotalResultPages,
                TotalResults       = searchResult.TotalResults,
                PageSize           = pagingOptions.PageSize ?? DefaultPageSize,
                CurrentPage        = pagingOptions.Page ?? FirstPage,
                SeoTitleTag        = categoryViewModel.Attributes.ValueByName("Custom Title"),
                SeoMetaDescription = categoryViewModel.Attributes.ValueByName("Meta Description"),
                SeoMetaKeywords    = categoryViewModel.Attributes.ValueByName("Meta Keywords")
            };

            viewMod.SetPageTitle(categoryViewModel.DisplayName);

            return(viewMod);
        }
        public void FilterIsReset()
        {
            var viewModel = new CatalogPageViewModel(null, movieRepository);

            viewModel.Genres[0].IsSelected = true;
            viewModel.Genres[1].IsSelected = true;
            viewModel.ResetGenresFilter();

            Assert.AreEqual(viewModel.Movies.Count, 3);
        }
        public void AllMoviesShownIfNoGenreSelected()
        {
            var viewModel = new CatalogPageViewModel(null, movieRepository);

            viewModel.Genres[0].IsSelected = false;
            viewModel.Genres[1].IsSelected = false;
            viewModel.Genres[2].IsSelected = false;

            Assert.AreEqual(viewModel.Movies.Count, 3);
        }
        public CatalogPage()
        {
            InitializeComponent();
            SetDefaults();

            var connectionString = ConnectionStringBuilder.Build(
                Settings.Default.server,
                Settings.Default.database,
                Settings.Default.user,
                Settings.Default.password);

            repository = new MovieRepository(connectionString);
            viewModel  = new CatalogPageViewModel(this, repository);

            DataContext = viewModel;
        }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CatalogListPage" /> class.
        /// </summary>
        public CatalogListPage(string selectedCategory)
        {
            InitializeComponent();
            var catalogDataService = App.MockDataService
                ? TypeLocator.Resolve <ICatalogDataService>()
                : DataService.TypeLocator.Resolve <ICatalogDataService>();
            var cartDataService = App.MockDataService
                ? TypeLocator.Resolve <ICartDataService>()
                : DataService.TypeLocator.Resolve <ICartDataService>();
            var wishlistDataService = App.MockDataService
                ? TypeLocator.Resolve <IWishlistDataService>()
                : DataService.TypeLocator.Resolve <IWishlistDataService>();

            BindingContext = new CatalogPageViewModel(GetType().Name, catalogDataService, cartDataService, wishlistDataService,
                                                      selectedCategory);
        }
        //
        public CatalogListPage(SubCategory category)
        {
            InitializeComponent();
            vm             = new CatalogPageViewModel(category);
            BindingContext = vm;

            /* ListViewList.FooterSize = 40;
             * visualContainer = ListViewList.GetType().GetRuntimeProperties().First(p => p.Name == "VisualContainer").GetValue(ListViewList) as VisualContainer;
             * scrollRows = visualContainer.GetType().GetRuntimeProperties().First(p => p.Name == "ScrollRows").GetValue(visualContainer) as ScrollAxisBase;
             * scrollRows.Changed += ScrollRows_Changed;
             */

            visualContainer = ListViewList.GetVisualContainer();
            visualContainer.ScrollRows.Changed += ScrollRows_Changed;

            /*  new Task(async () =>
             * {
             *    await getProducts(category);
             * }).Start();
             */
        }
        protected string GetPageTitle(CatalogPageViewModel model)
        {
            var title = GetPageTitleFromCurrentItem();

            if (!string.IsNullOrEmpty(title))
            {
                return(title);
            }

            if (model != null && !string.IsNullOrEmpty(model.Title))
            {
                var res = Res.PageTitle_Category;
                if (!string.IsNullOrEmpty(res))
                {
                    var idx = res.IndexOf(CategoryNameSubstititionToken, StringComparison.InvariantCultureIgnoreCase);
                    return(idx >= 0
                        ? res.Remove(idx, CategoryNameSubstititionToken.Length).Insert(idx, model.Title)
                        : res);
                }
            }

            return(GetPageTitleFromResource());
        }
Exemple #10
0
        private static CatalogPageViewModel GetDemoSearchResult()
        {
            var ret = new CatalogPageViewModel
            {
                CategoryId             = 1,
                CurrentPage            = 1,
                EnableFacets           = false,
                PageHasProdResultsPart = false,
                PageSize     = 20,
                TotalResults = 50,
                Products     = new Products()
            };

            var product = new Product[20];

            for (var i = 0; i < 20; i++)
            {
                product[i] = NewProduct();
            }

            ret.Products.Product = product;

            return(ret);
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CatalogListPage" /> class.
 /// </summary>
 public CatalogListPage()
 {
     InitializeComponent();
     this.BindingContext = VM = new CatalogPageViewModel(Navigation);
 }
 public CatalogPage()
 {
     this.InitializeComponent();
     ViewModel      = (CatalogPageViewModel)DataContext;
     ViewModel.View = this;
 }