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

45 lines
1.4 KiB
C#
Raw Normal View History

2020-02-17 08:58:14 +00:00
using ASC.Common;
using ASC.Core.Common.EF.Model;
2019-12-11 14:30:28 +00:00
using Microsoft.EntityFrameworkCore;
2020-10-06 11:38:15 +00:00
using System;
using System.Collections.Generic;
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() } ,
{ Provider.Postrge, () => new PostgreSqlVoipDbContext() } ,
};
}
}
2020-08-21 02:34:37 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
2020-09-06 22:49:03 +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>();
}
}
}