Ejemplo n.º 1
0
        private async Task PrepareCookieManagerModelAsync(CookieManagerModel model)
        {
            // Get cookie infos from plugins.
            model.CookiesInfos = (await _cookieConsentManager.GetAllCookieInfosAsync(true)).ToList();

            var cookie = _cookieConsentManager.GetCookieData();

            model.AnalyticsConsent   = cookie != null && cookie.AllowAnalytics;
            model.ThirdPartyConsent  = cookie != null && cookie.AllowThirdParty;
            model.ModalCookieConsent = _privacySettings.ModalCookieConsent;
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CookieInfoList(GridCommand command)
        {
            var data = await _cookieManager.GetAllCookieInfosAsync();

            var systemCookies = string.Join(",", data.Select(x => x.Name).ToArray());

            if (_privacySettings.CookieInfos.HasValue())
            {
                data.AddRange(JsonConvert.DeserializeObject <List <CookieInfo> >(_privacySettings.CookieInfos)
                              .OrderBy(x => x.CookieType)
                              .ThenBy(x => x.Name));
            }

            // TODO: (mh) (core) Remove test cookie
            systemCookies += " ,Test";
            data.Add(new CookieInfo {
                CookieType  = CookieType.Required,
                Name        = "Test",
                Description = "Test"
            });

            var gridModel = new GridModel <CookieInfoModel>
            {
                Rows = data
                       .Select(x =>
                {
                    return(new CookieInfoModel
                    {
                        CookieType = x.CookieType,
                        Name = x.Name,
                        Description = x.Description,
                        IsPluginInfo = systemCookies.Contains(x.Name),
                        CookieTypeName = x.CookieType.ToString()
                    });
                })
                       .ToList(),
                Total = data.Count
            };

            return(Json(gridModel));
        }