Updating SetupController to work with new [Required] attribute behavior

GET method no longer takes model as an argument
see also http://bradwilson.typepad.com/blog/2010/01/input-validation-vs-model-validation-in-aspnet-mvc.html

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-02-19 11:51:21 -08:00
parent f68c2d0f8a
commit dd9804ce12

View File

@@ -35,7 +35,7 @@ namespace Orchard.Setup.Controllers {
private Localizer T { get; set; }
public ActionResult Index(SetupViewModel model) {
private ActionResult IndexViewResult(SetupViewModel model) {
string message = "";
if (!CanWriteToAppDataFolder(out message)) {
_notifier.Error(
@@ -44,7 +44,11 @@ namespace Orchard.Setup.Controllers {
message));
}
return View(model ?? new SetupViewModel { AdminUsername = "admin" });
return View(model);
}
public ActionResult Index() {
return IndexViewResult(new SetupViewModel { AdminUsername = "admin" });
}
[HttpPost, ActionName("Index")]
@@ -54,7 +58,7 @@ namespace Orchard.Setup.Controllers {
ModelState.AddModelError("DatabaseConnectionString", "A SQL connection string is required");
if (!ModelState.IsValid) {
return Index(model);
return IndexViewResult(model);
}
try {
@@ -129,7 +133,7 @@ namespace Orchard.Setup.Controllers {
}
catch (Exception exception) {
_notifier.Error(T("Setup failed: " + exception.Message));
return Index(model);
return IndexViewResult(model);
}
}