using Mirea.Api.DataAccess.Persistence.Common; using Mirea.Api.Endpoint.Configuration.Validation.Attributes; using Mirea.Api.Endpoint.Configuration.Validation.Interfaces; using System; using System.Text.Json.Serialization; namespace Mirea.Api.Endpoint.Configuration.Model.GeneralSettings; [RequiredSettings] public class DbSettings : IIsConfigured { public enum DatabaseEnum { Mysql, Sqlite, PostgresSql } public DatabaseEnum TypeDatabase { get; set; } public required string ConnectionStringSql { get; set; } [JsonIgnore] public DatabaseProvider DatabaseProvider => TypeDatabase switch { DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql, DatabaseEnum.Mysql => DatabaseProvider.Mysql, DatabaseEnum.Sqlite => DatabaseProvider.Sqlite, _ => throw new ArgumentOutOfRangeException() }; public bool IsConfigured() => !string.IsNullOrEmpty(ConnectionStringSql); }