mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 12:53:33 +08:00
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:
@@ -35,7 +35,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
|
|
||||||
private Localizer T { get; set; }
|
private Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Index(SetupViewModel model) {
|
private ActionResult IndexViewResult(SetupViewModel model) {
|
||||||
string message = "";
|
string message = "";
|
||||||
if (!CanWriteToAppDataFolder(out message)) {
|
if (!CanWriteToAppDataFolder(out message)) {
|
||||||
_notifier.Error(
|
_notifier.Error(
|
||||||
@@ -44,7 +44,11 @@ namespace Orchard.Setup.Controllers {
|
|||||||
message));
|
message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return View(model ?? new SetupViewModel { AdminUsername = "admin" });
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Index() {
|
||||||
|
return IndexViewResult(new SetupViewModel { AdminUsername = "admin" });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Index")]
|
[HttpPost, ActionName("Index")]
|
||||||
@@ -54,7 +58,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
ModelState.AddModelError("DatabaseConnectionString", "A SQL connection string is required");
|
ModelState.AddModelError("DatabaseConnectionString", "A SQL connection string is required");
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
return Index(model);
|
return IndexViewResult(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -129,7 +133,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Setup failed: " + exception.Message));
|
_notifier.Error(T("Setup failed: " + exception.Message));
|
||||||
return Index(model);
|
return IndexViewResult(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user