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:
Erik Porter
2010-02-10 16:40:58 -08:00
parent 41ba3009e9
commit d3e35ff0a5
2 changed files with 13 additions and 5 deletions

View File

@@ -46,11 +46,15 @@ namespace Orchard.Setup.Controllers {
[HttpPost, ActionName("Index")]
public ActionResult IndexPOST(SetupViewModel model) {
try {
if (!ModelState.IsValid) {
return Index(model);
}
//HACK: (erikpo) Couldn't get a custom ValidationAttribute to validate two properties
if (!model.DatabaseOptions && string.IsNullOrEmpty(model.DatabaseConnectionString))
ModelState.AddModelError("DatabaseConnectionString", "A SQL connection string is required");
if (!ModelState.IsValid) {
return Index(model);
}
try {
var shellSettings = new ShellSettings {
Name = "default",
DataProvider = model.DatabaseOptions ? "SQLite" : "SqlServer",

View File

@@ -4,14 +4,18 @@ using Orchard.Mvc.ViewModels;
namespace Orchard.Setup.ViewModels {
public class SetupViewModel : BaseViewModel {
public SetupViewModel() {
DatabaseOptions = true;
}
[Required, StringLength(70)]
public string SiteName { get; set; }
[Required, StringLengthMin(3), StringLength(25)]
public string AdminUsername { get; set; }
[Required, StringLengthMin(6), StringLength(50)]
public string AdminPassword { get; set; }
public bool DatabaseOptions { get; set; }
[SqlDatabaseConnectionString]
public string DatabaseConnectionString { get; set; }
public bool DatabaseOptions { get; set; }
}
}