diff --git a/EventsZilla/Controllers/EventController.cs b/EventsZilla/Controllers/EventController.cs index 9103958..839c977 100644 --- a/EventsZilla/Controllers/EventController.cs +++ b/EventsZilla/Controllers/EventController.cs @@ -2,11 +2,10 @@ using System.Linq; using System.Web.Mvc; using EventsZilla.Models; -using HibernatingRhinos.Loci.Common.Controllers; namespace EventsZilla.Controllers { - public class EventController : RavenController + public class EventController : ZillaController { public ActionResult Index(int id, string slug) { diff --git a/EventsZilla/Controllers/HomeController.cs b/EventsZilla/Controllers/HomeController.cs index d75db54..f1452a9 100644 --- a/EventsZilla/Controllers/HomeController.cs +++ b/EventsZilla/Controllers/HomeController.cs @@ -2,11 +2,10 @@ using System.Web.Mvc; using System.Linq; using EventsZilla.Models; -using HibernatingRhinos.Loci.Common.Controllers; namespace EventsZilla.Controllers { - public class HomeController : RavenController + public class HomeController : ZillaController { public ActionResult Index() { diff --git a/EventsZilla/Controllers/ZillaController.cs b/EventsZilla/Controllers/ZillaController.cs new file mode 100644 index 0000000..ef75b3e --- /dev/null +++ b/EventsZilla/Controllers/ZillaController.cs @@ -0,0 +1,20 @@ +using System; +using System.Web.Mvc; +using EventsZilla.Models; +using HibernatingRhinos.Loci.Common.Controllers; + +namespace EventsZilla.Controllers +{ + public class ZillaController : RavenController + { + protected override void OnActionExecuting(ActionExecutingContext filterContext) + { + base.OnActionExecuting(filterContext); + + using (RavenSession.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(30))) + { + ViewBag.SiteConfig = RavenSession.Load(SiteConfig.ConfigName); + } + } + } +} \ No newline at end of file diff --git a/EventsZilla/EventsZilla.csproj b/EventsZilla/EventsZilla.csproj index b1fe70f..9148987 100644 --- a/EventsZilla/EventsZilla.csproj +++ b/EventsZilla/EventsZilla.csproj @@ -100,6 +100,7 @@ + @@ -114,6 +115,7 @@ + diff --git a/EventsZilla/Global.asax.cs b/EventsZilla/Global.asax.cs index 766afb4..4dd50aa 100644 --- a/EventsZilla/Global.asax.cs +++ b/EventsZilla/Global.asax.cs @@ -4,6 +4,7 @@ using System.Web; using System.Web.Mvc; using System.Web.Routing; +using EventsZilla.Models; using HibernatingRhinos.Loci.Common.Controllers; using HibernatingRhinos.Loci.Common.Routing; using HibernatingRhinos.Loci.Common.Tasks; @@ -60,8 +61,6 @@ protected void Application_Start() InitializeRaven(); - - RavenController.DocumentStore = _store; TaskExecutor.DocumentStore = _store; @@ -94,6 +93,15 @@ private static void InitializeRaven() IndexCreation.CreateIndexes(Assembly.GetCallingAssembly(), _store); + using (var session = _store.OpenSession()) + { + if (session.Load(SiteConfig.ConfigName) == null) + { + session.Store(new SiteConfig { RequireRegistration = true }, SiteConfig.ConfigName); + session.SaveChanges(); + } + } + ConfigureVersioning(); } catch (Exception e) diff --git a/EventsZilla/Models/SiteConfig.cs b/EventsZilla/Models/SiteConfig.cs new file mode 100644 index 0000000..a7b94d5 --- /dev/null +++ b/EventsZilla/Models/SiteConfig.cs @@ -0,0 +1,10 @@ +namespace EventsZilla.Models +{ + public class SiteConfig + { + public string WebsiteHeader { get; set; } + public bool RequireRegistration { get; set; } + + public static string ConfigName { get { return "Configs/Site"; } } + } +} \ No newline at end of file diff --git a/EventsZilla/Views/Shared/_Layout.cshtml b/EventsZilla/Views/Shared/_Layout.cshtml index 6d50880..da618f1 100644 --- a/EventsZilla/Views/Shared/_Layout.cshtml +++ b/EventsZilla/Views/Shared/_Layout.cshtml @@ -1,4 +1,8 @@ @using EventsZilla.Core +@using EventsZilla.Models +@{ + var siteConfig = ViewBag.SiteConfig as SiteConfig ?? new SiteConfig(); +} @@ -49,7 +53,9 @@ - @RenderBody() + @MvcHtmlString.Create(siteConfig.WebsiteHeader) + + @RenderBody()