Esempio n. 1
0
        public virtual IActionResult Category(string SeName, CatalogPagingFilteringModel command) //int categoryId, CatalogPagingFilteringModel command)
        {
            if (command.PageNumber == 1)
            {
                return(RedirectPermanent(_webHelper.RemoveQueryString(_webHelper.GetThisPageUrl(true), "pagenumber")));
            }
            int categoryId = _categoryService.GetCategoryIdBySeName(SeName);
            var category   = _categoryService.GetCategoryById(categoryId);

            if (category == null || category.Deleted)
            {
                return(InvokeHttp404());
            }

            var notAvailable =
                //published?
                !category.Published ||
                //ACL (access control list)
                !_aclService.Authorize(category) ||
                //Store mapping
                !_storeMappingService.Authorize(category);

            //Check whether the current user has a "Manage categories" permission (usually a store owner)
            //We should allows him (her) to use "Preview" functionality
            if (notAvailable && !_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(InvokeHttp404());
            }

            //'Continue shopping' URL
            //_genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
            //    NopCustomerDefaults.LastContinueShoppingPageAttribute,
            //    _webHelper.GetThisPageUrl(false),
            //    _storeContext.CurrentStore.Id);

            //display "edit" (manage) link
            if (_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && _permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                DisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = AreaNames.Admin }));
            }

            //activity log
            _customerActivityService.InsertActivity("PublicStore.ViewCategory",
                                                    string.Format(_localizationService.GetResource("ActivityLog.PublicStore.ViewCategory"), category.Name), category);

            //model
            var model = _catalogModelFactory.PrepareCategoryModel(category, command);

            var activeCategory = (category.ParentCategoryId != 0 ? category.ParentCategoryId : categoryId);

            ViewBag.ActiveCategory    = activeCategory;
            ViewBag.ActiveSubCategory = categoryId;
            //check if products in category has sleep sizes (for CatalogFiltersSelector)
            ViewBag.HasSleepSizes = activeCategory == 19;                         //id of category "Кровати", wich has sleep sizes
            ViewBag.HasHeight     = activeCategory == 21 || activeCategory == 19; //id of category "Кровати" "Тумбы и комоды", wich has sleep sizes
            //template
            var templateViewPath = _catalogModelFactory.PrepareCategoryTemplateViewPath(category.CategoryTemplateId);

            return(View(templateViewPath, model));
        }
        public virtual IActionResult Category(int categoryId, CatalogPagingFilteringModel command)
        {
            var category = _categoryService.GetCategoryById(categoryId);

            if (category == null || category.Deleted)
            {
                return(InvokeHttp404());
            }

            var notAvailable =
                //published?
                !category.Published ||
                //ACL (access control list)
                !_aclService.Authorize(category) ||
                //Store mapping
                !_storeMappingService.Authorize(category);

            //Check whether the current user has a "Manage categories" permission (usually a store owner)
            //We should allows him (her) to use "Preview" functionality
            if (notAvailable && !_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(InvokeHttp404());
            }

            //'Continue shopping' URL
            _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
                                                   NopCustomerDefaults.LastContinueShoppingPageAttribute,
                                                   _webHelper.GetThisPageUrl(false),
                                                   _storeContext.CurrentStore.Id);

            //display "edit" (manage) link
            if (_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && _permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                DisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = AreaNames.Admin }));
            }

            //activity log
            _customerActivityService.InsertActivity("PublicStore.ViewCategory",
                                                    string.Format(_localizationService.GetResource("ActivityLog.PublicStore.ViewCategory"), category.Name), category);

            //model
            var model = _catalogModelFactory.PrepareCategoryModel(category, command);

            //Link to product if category only contains single product
            if (model.Products.Count == 1)
            {
                return(Redirect("/" + model.Products[0].SeName));
            }

            //template
            var templateViewPath = _catalogModelFactory.PrepareCategoryTemplateViewPath(category.CategoryTemplateId);

            return(View(templateViewPath, model));
        }
Esempio n. 3
0
        public virtual IActionResult Category(int id, string title, CatalogPagingFilteringModel command)
        {
            var category = _categoryService.GetCategoryById(id);

            if (category == null || category.Deleted)
            {
                return(InvokeHttp404());
            }

            //model
            var model = _catalogModelFactory.PrepareCategoryModel(category, command);

            //template
            var templateViewPath = _catalogModelFactory.PrepareCategoryTemplateViewPath(category.CategoryTemplateId);

            return(View(templateViewPath, model));
        }
Esempio n. 4
0
        public virtual IActionResult Category(int categoryId, CatalogPagingFilteringModel command)
        {
            var category = _categoryService.GetCategoryById(categoryId);

            if (category == null || category.Deleted)
            {
                return(InvokeHttp404());
            }

            var notAvailable =
                //published?
                !category.Published ||
                //ACL (access control list)
                !_aclService.Authorize(category) ||
                //Store mapping
                !_storeMappingService.Authorize(category);

            //Check whether the current user has a "Manage categories" permission (usually a store owner)
            //We should allows him (her) to use "Preview" functionality
            if (notAvailable && !_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(InvokeHttp404());
            }

            //display "edit" (manage) link
            if (_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && _permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                DisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = AreaNames.Admin }));
            }

            //activity log
            _customerActivityService.InsertActivity("PublicStore.ViewCategory",
                                                    string.Format(_localizationService.GetResource("ActivityLog.PublicStore.ViewCategory"), category.Name), category);

            //model
            var model = _catalogModelFactory.PrepareCategoryModel(category, command);

            //template
            var templateViewPath = _catalogModelFactory.PrepareCategoryTemplateViewPath(category.CategoryTemplateId);

            return(View(templateViewPath, model));
        }