2024-10-25 08:47:11 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Demo.Data.RemoteData.RemoteDataBase.DAO;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Demo.Data.RemoteData.RemoteDataBase
|
|
|
|
|
{
|
|
|
|
|
public class RemoteDatabaseContext: DbContext
|
|
|
|
|
{
|
|
|
|
|
public DbSet<GroupDao> Groups { get; set; }
|
|
|
|
|
public DbSet<UserDao> Users { get; set; }
|
|
|
|
|
public DbSet<PresenceDao> PresenceDaos { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
2024-10-31 11:48:30 +00:00
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=presencedb;Username=postgres;Password=123;Include Error Detail=True;");
|
2024-10-25 08:47:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<GroupDao>().HasKey(group=>group.Id);
|
|
|
|
|
modelBuilder.Entity<GroupDao>().Property(group => group.Id).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<UserDao>().HasKey(user=>user.UserId);
|
|
|
|
|
modelBuilder.Entity<UserDao>().Property(user=>user.UserId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<PresenceDao>().HasKey(presence => new
|
|
|
|
|
{
|
|
|
|
|
presence.UserId,
|
|
|
|
|
presence.Date,
|
|
|
|
|
presence.IsAttedance,
|
|
|
|
|
presence.LessonNumber
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|