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

47 lines
1.4 KiB
C#
Raw Normal View History

2020-11-17 10:00:01 +00:00
using System;
using System.Collections.Generic;
using ASC.Common;
2020-02-17 08:58:14 +00:00
using ASC.Core.Common.EF.Model;
2020-10-12 16:23:15 +00:00
2019-12-11 14:30:28 +00:00
using Microsoft.EntityFrameworkCore;
2020-10-12 16:23:15 +00:00
2019-12-11 14:30:28 +00:00
namespace ASC.Core.Common.EF.Context
{
2020-10-06 11:38:15 +00:00
public class MySqlVoipDbContext : VoipDbContext { }
public class PostgreSqlVoipDbContext : VoipDbContext { }
public class VoipDbContext : BaseDbContext
2019-12-11 14:30:28 +00:00
{
public DbSet<VoipNumber> VoipNumbers { get; set; }
public DbSet<DbVoipCall> VoipCalls { get; set; }
public DbSet<CrmContact> CrmContact { get; set; }
2020-10-06 11:38:15 +00:00
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
{
return new Dictionary<Provider, Func<BaseDbContext>>()
{
{ Provider.MySql, () => new MySqlVoipDbContext() } ,
2020-10-08 09:07:05 +00:00
{ Provider.Postgre, () => new PostgreSqlVoipDbContext() } ,
2020-10-06 11:38:15 +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
.From(modelBuilder, Provider)
.AddVoipNumber()
.AddDbVoipCall()
2020-10-05 10:02:28 +00:00
.AddCrmContact();
2020-08-21 02:34:37 +00:00
}
2019-12-11 14:30:28 +00:00
}
public static class VoipDbExtension
{
2020-02-17 08:58:14 +00:00
public static DIHelper AddVoipDbContextService(this DIHelper services)
2019-12-11 14:30:28 +00:00
{
return services.AddDbContextManagerService<VoipDbContext>();
}
}
}