Move Available Databases to appsettings and use IOptions
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
@ -7,56 +9,18 @@ namespace Oqtane.Controllers
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class DatabaseController : Controller
|
||||
{
|
||||
public DatabaseController() { }
|
||||
private IOptions<List<Database>> _databaseOptions;
|
||||
|
||||
public DatabaseController(IOptions<List<Database>> databaseOptions)
|
||||
{
|
||||
_databaseOptions = databaseOptions;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
public IEnumerable<Models.Database> Get()
|
||||
{
|
||||
var databases = new List<Models.Database>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Name = "LocalDB",
|
||||
FriendlyName = "Local Database",
|
||||
ControlType = "Oqtane.Installer.Controls.LocalDBConfig, Oqtane.Client",
|
||||
DBType = "Oqtane.Database.SqlServer.SqlServerDatabase, Oqtane.Database.SqlServer",
|
||||
Package = "Oqtane.Database.SqlServer"
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "SqlServer",
|
||||
FriendlyName = "SQL Server",
|
||||
ControlType = "Oqtane.Installer.Controls.SqlServerConfig, Oqtane.Client",
|
||||
DBType = "Oqtane.Database.SqlServer.SqlServerDatabase, Oqtane.Database.SqlServer",
|
||||
Package = "Oqtane.Database.SqlServer"
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "Sqlite",
|
||||
FriendlyName = "Sqlite",
|
||||
ControlType = "Oqtane.Installer.Controls.SqliteConfig, Oqtane.Client",
|
||||
DBType = "Oqtane.Database.Sqlite.SqliteDatabase, Oqtane.Database.Sqlite",
|
||||
Package = "Oqtane.Database.Sqlite"
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "MySQL",
|
||||
FriendlyName = "MySQL",
|
||||
ControlType = "Oqtane.Installer.Controls.MySQLConfig, Oqtane.Client",
|
||||
DBType = "Oqtane.Database.MySQL.MySQLDatabase, Oqtane.Database.MySQL",
|
||||
Package = "Oqtane.Database.MySQL"
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "PostgreSQL",
|
||||
FriendlyName = "PostgreSQL",
|
||||
ControlType = "Oqtane.Installer.Controls.PostgreSQLConfig, Oqtane.Client",
|
||||
DBType = "Oqtane.Database.PostgreSQL.PostgreSQLDatabase, Oqtane.Database.PostgreSQL",
|
||||
Package = "Oqtane.Database.PostgreSQL"
|
||||
}
|
||||
};
|
||||
return databases;
|
||||
return _databaseOptions.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user