DocSpace-buildtools/common/ASC.Core.Common/EF/Context/VoipDbContext.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2022-02-15 11:52:43 +00:00
namespace ASC.Core.Common.EF.Context;
public class MySqlVoipDbContext : VoipDbContext { }
public class PostgreSqlVoipDbContext : VoipDbContext { }
public class VoipDbContext : BaseDbContext
2019-12-11 14:30:28 +00:00
{
2022-02-15 11:52:43 +00:00
public DbSet<VoipNumber> VoipNumbers { get; set; }
public DbSet<DbVoipCall> VoipCalls { get; set; }
public DbSet<CrmContact> CrmContact { get; set; }
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
2019-12-11 14:30:28 +00:00
{
2022-02-15 11:52:43 +00:00
get
2020-10-06 11:38:15 +00:00
{
2022-02-15 11:52:43 +00:00
return new Dictionary<Provider, Func<BaseDbContext>>()
2020-10-06 11:38:15 +00:00
{
2022-02-15 11:52:43 +00:00
{ Provider.MySql, () => new MySqlVoipDbContext() } ,
{ Provider.PostgreSql, () => new PostgreSqlVoipDbContext() } ,
};
2020-10-06 11:38:15 +00:00
}
2022-02-15 11:52:43 +00:00
}
2022-02-15 11:52:43 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddVoipNumber()
.AddDbVoipCall()
.AddCrmContact();
2019-12-11 14:30:28 +00:00
}
2022-02-15 11:52:43 +00:00
}
2019-12-11 14:30:28 +00:00
2022-02-15 11:52:43 +00:00
public static class VoipDbExtension
{
public static DIHelper AddVoipDbContextService(this DIHelper services)
2019-12-11 14:30:28 +00:00
{
2022-02-15 11:52:43 +00:00
return services.AddDbContextManagerService<VoipDbContext>();
2019-12-11 14:30:28 +00:00
}
}