2022-01-26 10:43:08 +00:00
|
|
|
|
namespace ASC.Core.Common.EF
|
2019-11-25 09:49:12 +00:00
|
|
|
|
{
|
2021-10-25 17:52:13 +00:00
|
|
|
|
public class MySqlUserDbContext : UserDbContext { }
|
2020-10-06 07:06:18 +00:00
|
|
|
|
|
|
|
|
|
|
2021-10-12 10:23:20 +00:00
|
|
|
|
public class PostgreSqlUserDbContext : UserDbContext
|
2020-10-06 07:06:18 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-05 09:27:15 +00:00
|
|
|
|
public class UserDbContext : BaseDbContext
|
2019-11-25 09:49:12 +00:00
|
|
|
|
{
|
|
|
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
|
public DbSet<UserSecurity> UserSecurity { get; set; }
|
|
|
|
|
public DbSet<UserPhoto> Photos { get; set; }
|
|
|
|
|
public DbSet<Acl> Acl { get; set; }
|
|
|
|
|
public DbSet<DbGroup> Groups { get; set; }
|
|
|
|
|
public DbSet<UserGroup> UserGroups { get; set; }
|
|
|
|
|
public DbSet<Subscription> Subscriptions { get; set; }
|
2019-12-02 12:04:22 +00:00
|
|
|
|
public DbSet<DbSubscriptionMethod> SubscriptionMethods { get; set; }
|
2019-11-25 09:49:12 +00:00
|
|
|
|
|
2020-10-06 07:06:18 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
|
|
|
{
|
|
|
|
|
{ Provider.MySql, () => new MySqlUserDbContext() } ,
|
2021-10-12 10:23:20 +00:00
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlUserDbContext() } ,
|
2020-10-06 07:06:18 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-17 08:27:38 +00:00
|
|
|
|
|
2019-11-25 11:49:21 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
2019-11-25 09:49:12 +00:00
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
ModelBuilderWrapper
|
2020-09-02 15:23:39 +00:00
|
|
|
|
.From(modelBuilder, Provider)
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.AddSubscriptionMethod()
|
2020-09-02 15:23:39 +00:00
|
|
|
|
.AddUser()
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.AddAcl()
|
|
|
|
|
.AddUserSecurity()
|
|
|
|
|
.AddUserPhoto()
|
|
|
|
|
.AddDbGroup()
|
|
|
|
|
.AddUserGroup()
|
2020-10-05 10:02:28 +00:00
|
|
|
|
.AddSubscription();
|
2019-11-25 09:49:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-02 12:04:22 +00:00
|
|
|
|
|
|
|
|
|
public static class UserDbExtension
|
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
|
public static DIHelper AddUserDbContextService(this DIHelper services)
|
2019-12-02 12:04:22 +00:00
|
|
|
|
{
|
2019-12-10 15:06:51 +00:00
|
|
|
|
return services.AddDbContextManagerService<UserDbContext>();
|
2019-12-02 12:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-25 09:49:12 +00:00
|
|
|
|
}
|