New source control repo for Biskilog POS - secure hub to store & manage source code. Streamlines dev process, tracks changes, & improves collaboration. Ensures reliable software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
2.1 KiB

using Biskilog_Accounting.Server.POSModels;
using Biskilog_Accounting.Shared.ClientContractModels;
using Biskilog_Accounting.Shared.Enums;
using Biskilog_Accounting.Shared.Interfaces;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace Biskilog_Accounting.Server.Services
{
public class ConnectionService : IConnectionService
{
private readonly BiskilogContext m_context;
private readonly IConfiguration m_configuration;
public ConnectionService(BiskilogContext a_context, IConfiguration configuration)
{
m_context = a_context;
m_configuration = configuration;
}
/// <summary>
/// Prepares and returns the connection string for a client using the specified database id
/// </summary>
/// <param name="a_databaseId">Specified database id to use</param>
/// <returns></returns>
public string GetClientConnectionString(int a_databaseId)
{
Databasemap? dbMap = m_context.Databasemaps.Find(a_databaseId);
if (dbMap != null)
{
string rawConString = m_configuration.GetConnectionString("PrivateConnection")!.ToString();
return String.Format(rawConString, dbMap.Domain, dbMap.DbName);
}
return ConnectionEnums.ConnectionNotEstablished.ToString();
}
/// <summary>
/// Prepare the DB context from the specified connection string
/// </summary>
/// <param name="a_context"></param>
/// <param name="a_connectionString"></param>
/// <returns>A configured BiskAcdbContext</returns>
public object PrepareDBContext(string a_connectionString)
{
throw new NotImplementedException();
//DbContextOptionsBuilder<BiskAcdbContext> acdbContext = new DbContextOptionsBuilder<BiskAcdbContext>();
//acdbContext.UseMySql(a_connectionString, new MariaDbServerVersion(new Version()));
//return new BiskAcdbContext(acdbContext.Options);
}
}
}