|
|
|
@ -1,21 +1,70 @@
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Entities.SQLudeoDB;
|
|
|
|
|
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
|
|
|
|
namespace DbContextLib
|
|
|
|
|
{
|
|
|
|
|
public class UserDbContext : DbContext
|
|
|
|
|
{
|
|
|
|
|
public DbSet<UserEntity> Users { get; set; }
|
|
|
|
|
public DbSet<BlackListEntity> BlackList { get; set; }
|
|
|
|
|
public DbSet<InquiryEntity> Inquiry { get; set; }
|
|
|
|
|
public DbSet<InquiryTableEntity> InquiryTable { get; set; }
|
|
|
|
|
public DbSet<LessonEntity> Lesson { get; set; }
|
|
|
|
|
public DbSet<ContentLessonEntity> ContentLessons { get; set; }
|
|
|
|
|
public DbSet<ParagraphEntity> Paragraph { get; set; }
|
|
|
|
|
public DbSet<SolutionEntity> Solutions { get; set; }
|
|
|
|
|
public DbSet<SuccessEntity> Success { get; set; }
|
|
|
|
|
public DbSet<NotepadEntity> Notepad { get; set; }
|
|
|
|
|
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options) { }
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
|
|
|
|
if (!optionsBuilder.IsConfigured)
|
|
|
|
|
{
|
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=password");
|
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse");
|
|
|
|
|
}
|
|
|
|
|
base.OnConfiguring(optionsBuilder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<UserEntity>().ToTable("user");
|
|
|
|
|
modelBuilder.Entity<UserEntity>().HasData(
|
|
|
|
|
new UserEntity(1, "johnny", Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
|
|
|
|
password: "motdepasse",
|
|
|
|
|
salt: RandomNumberGenerator.GetBytes(128 / 8),
|
|
|
|
|
prf: KeyDerivationPrf.HMACSHA256,
|
|
|
|
|
iterationCount: 100000,
|
|
|
|
|
numBytesRequested: 256 / 8)), "Johnny.RATTON@etu.uca.fr", true),
|
|
|
|
|
new UserEntity(2, "maxime", Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
|
|
|
|
password: "motdepasse",
|
|
|
|
|
salt: RandomNumberGenerator.GetBytes(128 / 8),
|
|
|
|
|
prf: KeyDerivationPrf.HMACSHA256,
|
|
|
|
|
iterationCount: 100000,
|
|
|
|
|
numBytesRequested: 256 / 8)), "Maxime.SAPOUNTZIS@etu.uca.fr", true),
|
|
|
|
|
new UserEntity(3, "clement", Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
|
|
|
|
password: "motdepasse",
|
|
|
|
|
salt: RandomNumberGenerator.GetBytes(128 / 8),
|
|
|
|
|
prf: KeyDerivationPrf.HMACSHA256,
|
|
|
|
|
iterationCount: 100000,
|
|
|
|
|
numBytesRequested: 256 / 8)), "Clement.CHIEU@etu.uca.fr", true),
|
|
|
|
|
new UserEntity(4, "erwan", Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
|
|
|
|
password: "motdepasse",
|
|
|
|
|
salt: RandomNumberGenerator.GetBytes(128 / 8),
|
|
|
|
|
prf: KeyDerivationPrf.HMACSHA256,
|
|
|
|
|
iterationCount: 100000,
|
|
|
|
|
numBytesRequested: 256 / 8)), "Erwan.MENAGER@etu.uca.fr", true),
|
|
|
|
|
new UserEntity(5, "victor", Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
|
|
|
|
password: "motdepasse",
|
|
|
|
|
salt: RandomNumberGenerator.GetBytes(128 / 8),
|
|
|
|
|
prf: KeyDerivationPrf.HMACSHA256,
|
|
|
|
|
iterationCount: 100000,
|
|
|
|
|
numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true));
|
|
|
|
|
modelBuilder.Entity<ContentLessonEntity>().HasKey(c => c.LessonId);
|
|
|
|
|
modelBuilder.Entity<ContentLessonEntity>().HasKey(c => c.LessonPartId);
|
|
|
|
|
modelBuilder.Entity<SuccessEntity>().HasKey(s => s.UserId);
|
|
|
|
|
modelBuilder.Entity<SuccessEntity>().HasKey(s => s.InquiryId);
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|