public virtual ActionResult CreateBlog(BlogConfig config) { var result = AssertConfigurationIsNeeded(); if (result != null) return result; if (!ModelState.IsValid) return View("Index"); // Create the blog by storing the config config.Id = "Blog/Config"; RavenSession.Store(config); // Create default sections RavenSession.Store(new Section { Title = "Archive", IsActive = true, Position = 1, ControllerName = "Section", ActionName = "ArchivesList" }); RavenSession.Store(new Section { Title = "Tags", IsActive = true, Position = 2, ControllerName = "Section", ActionName = "TagsList" }); RavenSession.Store(new Section { Title = "Statistics", IsActive = true, Position = 3, ControllerName = "Section", ActionName = "PostsStatistics" }); var user = new User { FullName = "Default User", Email = config.OwnerEmail, Enabled = true, }.SetPassword("raccoon"); RavenSession.Store(user); return RedirectToAction("Success", config); }
public ActionResult CreateBlog(BlogConfig config) { AssertConfigurationIsNeeded(); if (!ModelState.IsValid) return View("Index"); // Create the blog by storing the config config.Id = "Blog/Config"; Session.Store(config); // Create default sections Session.Store(new Section { Title = "Archive", IsActive = true, Position = 1, ControllerName = "Section", ActionName = "ArchivesList" }); Session.Store(new Section { Title = "Tags", IsActive = true, Position = 2, ControllerName = "Section", ActionName = "TagsList" }); Session.Store(new Section { Title = "Statistics", IsActive = true, Position = 3, ControllerName = "Section", ActionName = "PostsStatistics" }); var user = new User { FullName = "Default User", Email = "*****@*****.**", Enabled = true, }; user.SetPassword("raccoon"); Session.Store(user); return RedirectToAction("Success"); }
public virtual ActionResult Index(BlogConfig config) { if (ModelState.IsValid == false) { ViewBag.Message = ModelState.FirstErrorMessage(); if (Request.IsAjaxRequest()) return Json(new { Success = false, ViewBag.Message }); return View(BlogConfig); } var current = RavenSession.Load<BlogConfig>(BlogConfig.Key); if (IsFuturePostsEncryptionOptionsChanged(current, config)) { RemoveFutureRssAccessOnEncryptionConfigChange(); } RavenSession.Advanced.Evict(current); RavenSession.Store(config, BlogConfig.Key); RavenSession.SaveChanges(); OutputCacheManager.RemoveItem(MVC.Section.Name, MVC.Section.ActionNames.ContactMe); ViewBag.Message = "Configurations successfully saved!"; if (Request.IsAjaxRequest()) return Json(new { Success = true, ViewBag.Message }); return View(config); }
public static Credentials GetCredentials(BlogConfig blogConfig) { return new Credentials() { User = blogConfig.RedditUser, Password = blogConfig.RedditPassword }; }
public static IList<string> ParseSubreddits(BlogConfig config) { if (string.IsNullOrEmpty(config.RedditSubredditsToSubmitToOnPublish)) return new List<string>(); return config.RedditSubredditsToSubmitToOnPublish .Split(',') .Select(x => x.Trim()) .ToList(); }
public void WhenTheBlogConfigIsAvailable_ThePropertyShouldReturnTheConfig() { var config = new BlogConfig {Title = "Test Config", Id = "blog/config"}; SetupData(session => session.Store(config)); BlogConfig configFromController = null; ExecuteAction<LoginController>(controller => configFromController = controller.BlogConfig); Assert.Equal(config.Title, configFromController.Title); }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.IsChildAction) return; var blogConfig = Session.Load<BlogConfig>("Blog/Config"); if (blogConfig == null) { blogConfig = new BlogConfig(); Session.Store(blogConfig); } ViewBag.BlogConfig = blogConfig.MapTo<BlogConfigViewModel>(); }
public ActionResult Index(BlogConfig config) { if (ModelState.IsValid == false) { ViewBag.Message = ModelState.FirstErrorMessage(); if (Request.IsAjaxRequest()) return Json(new { Success = false, ViewBag.Message }); return View(BlogConfig); } RavenSession.Store(config); ViewBag.Message = "Configurations successfully saved!"; if (Request.IsAjaxRequest()) return Json(new { Success = true, ViewBag.Message }); return View(config); }
public virtual ActionResult Index(BlogConfig config) { if (ModelState.IsValid == false) { ViewBag.Message = ModelState.FirstErrorMessage(); if (Request.IsAjaxRequest()) return Json(new { Success = false, ViewBag.Message }); return View(BlogConfig); } RavenSession.Store(config, "Blog/Config"); OutputCacheManager.RemoveItem(MVC.Section.Name, MVC.Section.ActionNames.ContactMe); ViewBag.Message = "Configurations successfully saved!"; if (Request.IsAjaxRequest()) return Json(new { Success = true, ViewBag.Message }); return View(config); }
private static CryptographyUtil GetCrypto(BlogConfig blogConfig) { return new CryptographyUtil(blogConfig.FuturePostsEncryptionSalt, blogConfig.FuturePostsEncryptionIv); }
public static FutureRssAccessToken Parse(string token, BlogConfig blogConfig) { var json = GetCrypto(blogConfig).Decrypt(token, blogConfig.FuturePostsEncryptionKey); return JsonConvert.DeserializeObject<FutureRssAccessToken>(json); }
public string GetToken(BlogConfig blogConfig) { return GetCrypto(blogConfig).Encrypt(JsonConvert.SerializeObject(this), blogConfig.FuturePostsEncryptionKey); }
private bool IsFuturePostsEncryptionOptionsChanged(BlogConfig current, BlogConfig config) { return current.FuturePostsEncryptionKey != config.FuturePostsEncryptionKey || current.FuturePostsEncryptionIv != config.FuturePostsEncryptionIv || current.FuturePostsEncryptionSalt != config.FuturePostsEncryptionSalt; }