Ejemplo n.º 1
0
        public virtual ActionResult DestinationDelete(int discountId, int destinationId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
            {
                return(AccessDeniedView());
            }

            var discount = _discountService.GetDiscountById(discountId);

            if (discount == null)
            {
                throw new Exception("No discount found with the specified id");
            }

            var destination = _destinationService.GetDestinationById(destinationId);

            if (destination == null)
            {
                throw new Exception("No destination found with the specified id");
            }

            //remove discount
            if (destination.AppliedDiscounts.Count(d => d.Id == discount.Id) > 0)
            {
                destination.AppliedDiscounts.Remove(discount);
            }

            _destinationService.UpdateDestination(destination);

            return(new NullJsonResult());
        }
Ejemplo n.º 2
0
        //in versions 2.00-2.65 we had ID in destination URLs
        public virtual ActionResult RedirectDestinationById(int destinationId)
        {
            var destination = _destinationService.GetDestinationById(destinationId);

            if (destination == null)
            {
                return(RedirectToRoutePermanent("HomePage"));
            }

            return(RedirectToRoutePermanent("Destination", new { SeName = destination.GetSeName() }));
        }
        public virtual ActionResult RedirectDestination(string id, bool idIncludesSename = true)
        {
            //we can't use dash in MVC
            var destinationId = idIncludesSename ? Convert.ToInt32(id.Split(new [] { '-' })[0]) : Convert.ToInt32(id);
            var destination   = _destinationService.GetDestinationById(destinationId);

            if (destination == null)
            {
                return(RedirectToRoutePermanent("HomePage"));
            }

            return(RedirectToRoutePermanent("Destination", new { SeName = destination.GetSeName() }));
        }
Ejemplo n.º 4
0
        public virtual ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDestinations))
            {
                return(AccessDeniedView());
            }

            var destination = _destinationService.GetDestinationById(id);

            if (destination == null || destination.Deleted)
            {
                //No destination found with the specified id
                return(RedirectToAction("List"));
            }

            var model = destination.ToModel();

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name            = destination.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description     = destination.GetLocalized(x => x.Description, languageId, false, false);
                locale.MetaKeywords    = destination.GetLocalized(x => x.MetaKeywords, languageId, false, false);
                locale.MetaDescription = destination.GetLocalized(x => x.MetaDescription, languageId, false, false);
                locale.MetaTitle       = destination.GetLocalized(x => x.MetaTitle, languageId, false, false);
                locale.SeName          = destination.GetSeName(languageId, false, false);
            });
            //templates
            PrepareTemplatesModel(model);
            //discounts
            PrepareDiscountModel(model, destination, false);
            //ACL
            PrepareAclModel(model, destination, false);
            //Stores
            PrepareStoresMappingModel(model, destination, false);

            return(View(model));
        }
Ejemplo n.º 5
0
        public virtual ActionResult Destination(int destinationId, CatalogPagingFilteringModel command)
        {
            var destination = _destinationService.GetDestinationById(destinationId);

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

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

            //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.ManageDestinations))
            {
                return(InvokeHttp404());
            }

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

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

            //activity log
            _customerActivityService.InsertActivity("PublicStore.ViewDestination", _localizationService.GetResource("ActivityLog.PublicStore.ViewDestination"), destination.Name);

            //model
            var model = _catalogModelFactory.PrepareDestinationModel(destination, command);

            //template
            var templateViewPath = _catalogModelFactory.PrepareDestinationTemplateViewPath(destination.DestinationTemplateId);

            return(View(templateViewPath, model));
        }