SetupController setup post action and injection of notifier for error/status logging during setup

--HG--
branch : dev
This commit is contained in:
Suha Can
2010-02-05 13:36:01 -08:00
parent 55cdaadbe3
commit 913c3ae440
2 changed files with 26 additions and 9 deletions

View File

@@ -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");
}
}
}

View File

@@ -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<PageTitleBuilder>().As<IPageTitleBuilder>().ContainerScoped();
builder.Register<ZoneManager>().As<IZoneManager>().ContainerScoped();
builder.Register<PageClassBuilder>().As<IPageClassBuilder>().ContainerScoped();
builder.Register<Notifier>().As<INotifier>().ContainerScoped();
builder.Register<NotifyFilter>().As<IFilterProvider>().ContainerScoped();
// safe mode specific implementations of needed service interfaces
builder.Register<NullHackInstallationGenerator>().As<IHackInstallationGenerator>().ContainerScoped();