2022-01-26 10:43:08 +00:00
|
|
|
|
namespace ASC.Core.Common.EF.Context
|
2019-12-13 11:37:58 +00:00
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
public class MySqlMailDbContext : MailDbContext { }
|
|
|
|
|
public class PostgreSqlMailDbContext : MailDbContext { }
|
2020-10-05 09:27:15 +00:00
|
|
|
|
public class MailDbContext : BaseDbContext
|
2019-12-13 11:37:58 +00:00
|
|
|
|
{
|
|
|
|
|
public DbSet<MailboxServer> MailboxServer { get; set; }
|
|
|
|
|
public DbSet<ServerServer> ServerServer { get; set; }
|
|
|
|
|
public DbSet<MailboxProvider> MailboxProvider { get; set; }
|
|
|
|
|
public DbSet<Mailbox> Mailbox { get; set; }
|
|
|
|
|
public DbSet<ApiKeys> ApiKeys { get; set; }
|
|
|
|
|
public DbSet<GreyListingWhiteList> GreyListingWhiteList { get; set; }
|
|
|
|
|
|
|
|
|
|
public MailDbContext() { }
|
2020-10-09 15:52:17 +00:00
|
|
|
|
public MailDbContext(DbContextOptions options) : base(options) { }
|
2022-02-14 21:02:57 +00:00
|
|
|
|
|
2020-10-06 11:38:15 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
2019-12-13 11:37:58 +00:00
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
|
|
|
{
|
|
|
|
|
{ Provider.MySql, () => new MySqlMailDbContext() } ,
|
2021-10-12 10:23:20 +00:00
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlMailDbContext() } ,
|
2020-10-06 11:38:15 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2019-12-13 11:37:58 +00:00
|
|
|
|
}
|
2020-08-21 02:34:37 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
ModelBuilderWrapper
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.From(modelBuilder, Provider)
|
|
|
|
|
.AddMailbox()
|
|
|
|
|
.AddMailboxProvider()
|
2021-10-07 09:50:57 +00:00
|
|
|
|
.AddServerServer()
|
|
|
|
|
.AddGreyListingWhiteList();
|
2020-08-21 02:34:37 +00:00
|
|
|
|
}
|
2019-12-13 11:37:58 +00:00
|
|
|
|
}
|
2019-12-16 14:55:59 +00:00
|
|
|
|
public static class MailDbExtension
|
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
|
public static DIHelper AddMailDbContextService(this DIHelper services)
|
2019-12-16 14:55:59 +00:00
|
|
|
|
{
|
|
|
|
|
return services.AddDbContextManagerService<MailDbContext>();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-13 11:37:58 +00:00
|
|
|
|
}
|