2023-07-06 22:19:40 -07:00
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
2023-06-19 15:36:43 -07:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Newsbot.Collector.Domain.Consts;
|
|
|
|
using Newsbot.Collector.Domain.Entities;
|
|
|
|
|
|
|
|
namespace Newsbot.Collector.Database;
|
|
|
|
|
2023-07-06 22:19:40 -07:00
|
|
|
public class DatabaseContext : IdentityDbContext
|
2023-06-19 15:36:43 -07:00
|
|
|
{
|
|
|
|
public DbSet<ArticlesEntity> Articles { get; set; } = null!;
|
2023-07-09 21:29:33 -07:00
|
|
|
|
|
|
|
public DbSet<DiscordNotificationEntity> DiscordNotification { get; set; } = null!;
|
2023-06-19 15:36:43 -07:00
|
|
|
public DbSet<DiscordQueueEntity> DiscordQueue { get; set; } = null!;
|
|
|
|
public DbSet<DiscordWebhookEntity> DiscordWebhooks { get; set; } = null!;
|
|
|
|
public DbSet<IconEntity> Icons { get; set; } = null!;
|
|
|
|
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
|
|
|
|
2023-07-06 22:19:40 -07:00
|
|
|
//public DbSet<UserEntity> Users { get; set; } = null!;
|
|
|
|
|
|
|
|
private string ConnectionString { get; set; } = "";
|
|
|
|
|
|
|
|
//public DatabaseContext(IConfiguration appsettings, string connectionString)
|
|
|
|
//{
|
|
|
|
// var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
|
|
|
|
// ConnectionString = connString ?? "";
|
|
|
|
//}
|
2023-06-19 15:36:43 -07:00
|
|
|
|
|
|
|
public DatabaseContext(string connectionString)
|
|
|
|
{
|
|
|
|
ConnectionString = connectionString;
|
|
|
|
}
|
2023-06-25 21:04:31 -07:00
|
|
|
|
2023-07-06 22:19:40 -07:00
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
2023-06-25 21:04:31 -07:00
|
|
|
{
|
2023-07-06 22:19:40 -07:00
|
|
|
if (ConnectionString != "")
|
|
|
|
{
|
|
|
|
options.UseNpgsql(ConnectionString);
|
|
|
|
}
|
2023-06-25 21:04:31 -07:00
|
|
|
}
|
2023-07-06 22:19:40 -07:00
|
|
|
|
|
|
|
//public DatabaseContext(DbContextOptions<DatabaseContext> connectionString)
|
|
|
|
//{
|
|
|
|
// ConnectionString = "";
|
|
|
|
//}
|
2023-06-25 21:04:31 -07:00
|
|
|
|
2023-07-06 22:19:40 -07:00
|
|
|
//public DatabaseContext()
|
|
|
|
//{
|
|
|
|
// ConnectionString = "";
|
|
|
|
//}
|
2023-06-19 15:36:43 -07:00
|
|
|
|
2023-07-06 22:19:40 -07:00
|
|
|
|
|
|
|
public DatabaseContext(DbContextOptions<DatabaseContext> options)
|
|
|
|
: base(options)
|
2023-06-19 15:36:43 -07:00
|
|
|
{
|
2023-07-06 22:19:40 -07:00
|
|
|
//ConnectionString = "";
|
|
|
|
|
2023-06-19 15:36:43 -07:00
|
|
|
}
|
|
|
|
|
2023-06-25 21:04:31 -07:00
|
|
|
public DatabaseContext(DbContextOptions<DatabaseContext> options, string connectionString)
|
2023-06-19 15:36:43 -07:00
|
|
|
: base(options)
|
|
|
|
{
|
2023-07-06 22:19:40 -07:00
|
|
|
//ConnectionString = connectionString;
|
2023-06-19 15:36:43 -07:00
|
|
|
}
|
|
|
|
}
|