public ActionResult CookieConsentBadge()
        {
            if (!_privacySettings.EnableCookieConsent)
            {
                return(new EmptyResult());
            }

            if (CookieConsent.GetStatus(this.ControllerContext.ParentActionViewContext) != CookieConsentStatus.Asked)
            {
                return(new EmptyResult());
            }

            var model = new CookieConsentModel();

            if (!_privacySettings.CookieConsentBadgetext.HasValue())
            {
                // Loads default value if it's empty (must be done this way as localized values can't be initial values of settings)
                model.BadgeText = T("CookieConsent.BadgeText", Services.StoreContext.CurrentStore.Name, Url.Topic("PrivacyInfo"));
            }
            else
            {
                model.BadgeText = _privacySettings.GetLocalized(x => x.CookieConsentBadgetext).Value.FormatWith(Services.StoreContext.CurrentStore.Name, Url.Topic("PrivacyInfo"));
            }

            return(PartialView(model));
        }
Пример #2
0
        public ActionResult CookieConsentBadge()
        {
            if (!_privacySettings.EnableCookieConsent)
            {
                return(new EmptyResult());
            }

            var model = new CookieConsentModel();

            if (!_privacySettings.CookieConsentBadgetext.HasValue())
            {
                // loads default value if it's empty (must be done this way as localized values can't be initial values of settings)
                model.BadgeText = T("CookieConsent.BadgeText",
                                    _services.StoreContext.CurrentStore.Name,
                                    Url.RouteUrl("Topic", new { SeName = Url.TopicSeName("PrivacyInfo") }));
            }
            else
            {
                model.BadgeText = _privacySettings.GetLocalized(x => x.CookieConsentBadgetext).Value.FormatWith(
                    _services.StoreContext.CurrentStore.Name,
                    Url.RouteUrl("Topic", new { SystemName = "PrivacyInfo" })
                    );
            }

            var consentCookie = this.Request.Cookies[CookieConsent.CONSENT_COOKIE_NAME];

            if (consentCookie != null && consentCookie.Value == "true")
            {
                return(new EmptyResult());
            }

            return(PartialView(model));
        }