From 913c3ae4401a7c484c45474f6f62fe98ff99c75a Mon Sep 17 00:00:00 2001 From: Suha Can Date: Fri, 5 Feb 2010 13:36:01 -0800 Subject: [PATCH] SetupController setup post action and injection of notifier for error/status logging during setup --HG-- branch : dev --- .../Core/Setup/Controllers/SetupController.cs | 29 ++++++++++++++----- .../SafeModeShellContainerFactory.cs | 6 ++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/Orchard.Web/Core/Setup/Controllers/SetupController.cs b/src/Orchard.Web/Core/Setup/Controllers/SetupController.cs index f2a2a7524..8e6b0f2f7 100644 --- a/src/Orchard.Web/Core/Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Core/Setup/Controllers/SetupController.cs @@ -1,23 +1,38 @@ using System.Web.Mvc; -using Orchard.Core.Setup.Services; using Orchard.Core.Setup.ViewModels; using Orchard.Localization; -using Orchard.Logging; +using Orchard.UI.Notify; namespace Orchard.Core.Setup.Controllers { public class SetupController : Controller { + private readonly INotifier _notifier; - public SetupController() { - Logger = NullLogger.Instance; + public SetupController(INotifier notifier) { + _notifier = notifier; T = NullLocalizer.Instance; } - public IOrchardServices Services { get; set; } - public ILogger Logger { get; set; } private Localizer T { get; set; } public ActionResult Index() { - return View(new SetupViewModel()); + return View(new SetupViewModel { AdminUsername = "admin" }); + } + + [HttpPost] + public ActionResult Index(SetupViewModel model) { + TryUpdateModel(model); + + if (!ModelState.IsValid) { + return View(model); + } + + // create superuser + // set site name + // database + // redirect to the welcome page + + _notifier.Information(T("Setup succeeded")); + return RedirectToAction("Index"); } } } diff --git a/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs b/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs index d346dc127..fa80378e9 100644 --- a/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs +++ b/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Web; using System.Web.Mvc; using System.Web.Routing; @@ -16,6 +15,7 @@ using Orchard.Mvc.Routes; using Orchard.Mvc.ViewEngines; using Orchard.Settings; using Orchard.Themes; +using Orchard.UI.Notify; using Orchard.UI.PageClass; using Orchard.UI.PageTitle; using Orchard.UI.Zones; @@ -48,6 +48,8 @@ namespace Orchard.Environment.ShellBuilders { builder.Register().As().ContainerScoped(); builder.Register().As().ContainerScoped(); builder.Register().As().ContainerScoped(); + builder.Register().As().ContainerScoped(); + builder.Register().As().ContainerScoped(); // safe mode specific implementations of needed service interfaces builder.Register().As().ContainerScoped();