mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Changed the default value for SetupViewModel to be the built-in database option and added a check to ensure a connection string was entered when the sql database option is checked
--HG-- branch : dev
This commit is contained in:
@@ -46,11 +46,15 @@ namespace Orchard.Setup.Controllers {
|
|||||||
|
|
||||||
[HttpPost, ActionName("Index")]
|
[HttpPost, ActionName("Index")]
|
||||||
public ActionResult IndexPOST(SetupViewModel model) {
|
public ActionResult IndexPOST(SetupViewModel model) {
|
||||||
try {
|
//HACK: (erikpo) Couldn't get a custom ValidationAttribute to validate two properties
|
||||||
if (!ModelState.IsValid) {
|
if (!model.DatabaseOptions && string.IsNullOrEmpty(model.DatabaseConnectionString))
|
||||||
return Index(model);
|
ModelState.AddModelError("DatabaseConnectionString", "A SQL connection string is required");
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!ModelState.IsValid) {
|
||||||
|
return Index(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
var shellSettings = new ShellSettings {
|
var shellSettings = new ShellSettings {
|
||||||
Name = "default",
|
Name = "default",
|
||||||
DataProvider = model.DatabaseOptions ? "SQLite" : "SqlServer",
|
DataProvider = model.DatabaseOptions ? "SQLite" : "SqlServer",
|
||||||
|
@@ -4,14 +4,18 @@ using Orchard.Mvc.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Setup.ViewModels {
|
namespace Orchard.Setup.ViewModels {
|
||||||
public class SetupViewModel : BaseViewModel {
|
public class SetupViewModel : BaseViewModel {
|
||||||
|
public SetupViewModel() {
|
||||||
|
DatabaseOptions = true;
|
||||||
|
}
|
||||||
|
|
||||||
[Required, StringLength(70)]
|
[Required, StringLength(70)]
|
||||||
public string SiteName { get; set; }
|
public string SiteName { get; set; }
|
||||||
[Required, StringLengthMin(3), StringLength(25)]
|
[Required, StringLengthMin(3), StringLength(25)]
|
||||||
public string AdminUsername { get; set; }
|
public string AdminUsername { get; set; }
|
||||||
[Required, StringLengthMin(6), StringLength(50)]
|
[Required, StringLengthMin(6), StringLength(50)]
|
||||||
public string AdminPassword { get; set; }
|
public string AdminPassword { get; set; }
|
||||||
|
public bool DatabaseOptions { get; set; }
|
||||||
[SqlDatabaseConnectionString]
|
[SqlDatabaseConnectionString]
|
||||||
public string DatabaseConnectionString { get; set; }
|
public string DatabaseConnectionString { get; set; }
|
||||||
public bool DatabaseOptions { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user