Пример #1
0
        public ActionResult Index()
        {
            var script = new StringBuilder()
                .AddRelative("~/scripts/privacyController.js");

            Response.ContentType = "text/javascript";

            IDictionary<string, bool> result = new Dictionary<string, bool>();
            var loader = new PrivacyLoader(Request);
            var source = loader.Load();

            if (!string.IsNullOrWhiteSpace(source))
                using (var reader = new PrivacyReader(source))
                    result = reader.ReadAll();

            var policies = expectedPrivacies.Select(e =>
                                                    new PrivacySettingViewModel
                                                    {
                                                        Name = e,
                                                        Setting = result.ContainsKey(e) ? result[e] : (bool?)null
                                                    });

            var userPolicies = GetSettings().Select(e =>
                                                   new PrivacySettingViewModel
                                                   {
                                                       Name = e.Key,
                                                       Setting = e.Value
                                                   });

            return View(new PrivacyScriptViewModel { Policies = policies, Script = script.ToString(), UserSettings = userPolicies });
        }
Пример #2
0
        public ActionResult SiteInfo(Uri url)
        {
            if (url == null)
                return HttpNotFound();

            IDictionary<string, bool> result;
            var loader = new PrivacyLoader(Request);
            var source = loader.Load();

            if (string.IsNullOrWhiteSpace(source))
            {
                result = new Dictionary<string, bool>();
            }
            else
            {
                using (var reader = new PrivacyReader(source))
                    result = reader.ReadAll();
            }

            var policies = expectedPrivacies.Select(e =>
                                                    new PrivacySettingViewModel
                                                    {
                                                        Name = e,
                                                        Setting = result.ContainsKey(e) ? result[e] : (bool?)null
                                                    });

            var userPolicies = GetSettings().Select(e =>
                                                   new PrivacySettingViewModel
                                                   {
                                                       Name = e.Key,
                                                       Setting = e.Value
                                                   });

            return View(new PrivacytViewModel {Policies = policies, UserSettings = userPolicies, BaseSettings = expectedPrivacies, Site = url});
        }
Пример #3
0
        public void Can_load()
        {
            //Arrange
            var privacyLoader = new PrivacyLoader(new RequestMock());

            //Act
            var load = privacyLoader.Load();

            //Assert
            Assert.That(!String.IsNullOrWhiteSpace(load));
        }