Beispiel #1
0
        public virtual async Task <IActionResult> Manufacturer(string manufacturerId, CatalogPagingFilteringModel command)
        {
            var manufacturer = await _catalogViewModelService.GetManufacturerById(manufacturerId);

            if (manufacturer == null)
            {
                return(InvokeHttp404());
            }

            var customer = _workContext.CurrentCustomer;

            //Check whether the current user has a "Manage catalog" permission
            //It allows him to preview a manufacturer before publishing
            if (!manufacturer.Published && !await _permissionService.Authorize(StandardPermissionProvider.ManageManufacturers, customer))
            {
                return(InvokeHttp404());
            }

            //ACL (access control list)
            if (!_aclService.Authorize(manufacturer, customer))
            {
                return(InvokeHttp404());
            }

            //Store mapping
            if (!_storeMappingService.Authorize(manufacturer))
            {
                return(InvokeHttp404());
            }

            //'Continue shopping' URL
            await SaveLastContinueShoppingPage(customer);

            //display "edit" (manage) link
            if (await _permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel, customer) && await _permissionService.Authorize(StandardPermissionProvider.ManageManufacturers, customer))
            {
                DisplayEditLink(Url.Action("Edit", "Manufacturer", new { id = manufacturer.Id, area = "Admin" }));
            }

            //activity log
            await _customerActivityService.InsertActivity("PublicStore.ViewManufacturer", manufacturer.Id, _localizationService.GetResource("ActivityLog.PublicStore.ViewManufacturer"), manufacturer.Name);

            await _customerActionEventService.Viewed(customer, this.HttpContext.Request.Path.ToString(), this.Request.Headers[HeaderNames.Referer].ToString() != null?Request.Headers[HeaderNames.Referer].ToString() : "");

            //model
            var model = await _catalogViewModelService.PrepareManufacturer(manufacturer, command);

            //template
            var templateViewPath = await _catalogViewModelService.PrepareManufacturerTemplateViewPath(manufacturer.ManufacturerTemplateId);

            return(View(templateViewPath, model));
        }