2024-10-24 11:43:25 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
2024-10-25 07:59:32 +00:00
|
|
|
|
public class RemoteDateBaseContext : DbContext
|
2024-10-24 11:43:25 +00:00
|
|
|
|
{
|
2024-10-25 07:59:32 +00:00
|
|
|
|
public RemoteDateBaseContext() { }
|
2024-10-24 11:43:25 +00:00
|
|
|
|
|
2024-10-25 07:59:32 +00:00
|
|
|
|
public DbSet<GroupDao> Group { get; set; }
|
|
|
|
|
public DbSet<UserDao> User { get; set; }
|
|
|
|
|
public DbSet<PresnceDao> Presence { get; set; }
|
2024-10-25 09:40:13 +00:00
|
|
|
|
public object Groups { get; internal set; }
|
2024-10-24 11:43:25 +00:00
|
|
|
|
|
2024-10-25 07:59:32 +00:00
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
2024-10-25 09:40:13 +00:00
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Username=postgres;Password=123;Database=postgres");
|
2024-10-25 07:59:32 +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.Guid);
|
|
|
|
|
modelBuilder.Entity<UserDao>().Property(user => user.Guid).ValueGeneratedOnAdd();
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<PresnceDao>().HasKey(presence => new
|
|
|
|
|
{
|
|
|
|
|
presence.UserGuid,
|
|
|
|
|
presence.Date,
|
|
|
|
|
presence.IsAttendensy,
|
|
|
|
|
presence.LessonNumber
|
|
|
|
|
});
|
2024-10-24 11:43:25 +00:00
|
|
|
|
}
|
2024-10-25 09:20:05 +00:00
|
|
|
|
}
|