@namespace Oqtane.Installer.Controls
@implements Oqtane.Interfaces.IDatabaseConfigControl

<div class="row mb-1 align-items-center">
    <Label Class="col-sm-3" For="server" HelpText="Enter the database server" ResourceKey="Server">Server:</Label>
    <div class="col-sm-9">
        <input id="server" type="text" class="form-control" @bind="@_server" />
    </div>
</div>
<div class="row mb-1 align-items-center">
    <Label Class="col-sm-3" For="database" HelpText="Enter the name of the database" ResourceKey="Database">Database:</Label>
    <div class="col-sm-9">
        <input id="database" type="text" class="form-control" @bind="@_database" />
    </div>
</div>

@code {
    private string _server = "(LocalDb)\\MSSQLLocalDB";
    private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");

    public string GetConnectionString()
    {
        var connectionString = String.Empty;

        if (!String.IsNullOrEmpty(_server) && !String.IsNullOrEmpty(_database))
        {
            connectionString = $"Data Source={_server};AttachDbFilename=|DataDirectory|\\{_database}.mdf;Initial Catalog={_database};Integrated Security=SSPI;Encrypt=false;";
        }

        return connectionString;
    }
}