DocSpace-client/common/ASC.Core.Common/EF/Context/MailDbContext.cs

54 lines
1.8 KiB
C#
Raw Normal View History

2020-10-09 15:52:17 +00:00
using System;
using System.Collections.Generic;
using ASC.Common;
2020-09-06 22:49:03 +00:00
using ASC.Core.Common.EF.Model;
2020-02-17 08:58:14 +00:00
using ASC.Core.Common.EF.Model.Mail;
2020-10-09 15:52:17 +00:00
2019-12-13 11:37:58 +00:00
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Context
{
2020-10-06 11:38:15 +00:00
public class MySqlMailDbContext : MailDbContext { }
public class PostgreSqlMailDbContext : MailDbContext { }
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) { }
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
}