Example #1
0
 public ShoppingCategories()
 {
     InitializeComponent();
     using (var scope = Dependencies.container.BeginLifetimeScope())
     {
         SCVM = Dependencies.container.Resolve <ShoppingCategoryViewModel>();
     }
     //   RPVM = new RegistrationDataPageViewModel(new NavigationService(),new LocationServices())
     BindingContext = SCVM;
 }
        public ActionResult Index(ShoppingCategoryPage currentPage)
        {
            var model = new ShoppingCategoryViewModel(currentPage);

            model.Language = currentPage.Language.Name;

            if (currentPage.CatalogNodes != null)
            {
                model.CommerceCategoryIds = GetCommerceNodeIds(currentPage);
            }

            model.NumberOfProductsToShow = currentPage.NumberOfProductsToShow > 0 ? currentPage.NumberOfProductsToShow : DefaultNumProductsInList;

            if (currentPage.ParentLink != null)
            {
                var languageSelector         = new LanguageSelector(model.Language);
                var parent                   = _contentLoader.Get <IContent>(currentPage.ParentLink, languageSelector);
                ShoppingCategoryPage topNode = null;

                while (!(parent is HomePage))
                {
                    topNode = parent as ShoppingCategoryPage;
                    parent  = _contentLoader.Get <IContent>(parent.ParentLink, languageSelector);
                }

                if (topNode == null && parent is HomePage)
                {
                    topNode = currentPage;
                    model.CommerceCategoryIds = string.Empty;
                }
                if (topNode != null)
                {
                    model.ParentName               = topNode.Name;
                    model.CategoryPages            = _contentLoader.GetChildren <ShoppingCategoryPage>(topNode.ContentLink);
                    model.CommerceRootCategoryName = GetCommerceNodeNames(topNode);
                }
            }

            return(View(model));
        }
        public ShoppingCategories()
        {
            InitializeComponent();

            BindingContext = new ShoppingCategoryViewModel(this.Navigation);
        }