Use the configuration depending on the selected database provider #13

Merged
Wesser merged 33 commits from feat/database-persistence into feat/add-setup 2024-06-01 05:45:18 +03:00
Showing only changes of commit 62ccf94222 - Show all commits

View File

@ -1,4 +1,6 @@
using Mirea.Api.Endpoint.Configuration.General.Attributes; using System;
using Mirea.Api.DataAccess.Persistence.Common;
using Mirea.Api.Endpoint.Configuration.General.Attributes;
using Mirea.Api.Endpoint.Configuration.General.Interfaces; using Mirea.Api.Endpoint.Configuration.General.Interfaces;
namespace Mirea.Api.Endpoint.Configuration.General.Settings; namespace Mirea.Api.Endpoint.Configuration.General.Settings;
@ -15,8 +17,15 @@ public class DbSettings : IIsConfigured
public DatabaseEnum TypeDatabase { get; set; } public DatabaseEnum TypeDatabase { get; set; }
public required string ConnectionStringSql { get; set; } public required string ConnectionStringSql { get; set; }
public bool IsConfigured() public DatabaseProvider DatabaseProvider =>
TypeDatabase switch
{ {
return !string.IsNullOrEmpty(ConnectionStringSql); DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql,
} DatabaseEnum.Mysql => DatabaseProvider.Mysql,
DatabaseEnum.Sqlite => DatabaseProvider.Sqlite,
_ => throw new ArgumentOutOfRangeException()
};
public bool IsConfigured() =>
!string.IsNullOrEmpty(ConnectionStringSql);
} }