66 lines
1.4 KiB
C#
66 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Diplom_O.DataBase
|
|
{
|
|
public class MainDB : DbContext
|
|
{
|
|
public DbSet<Shtat> Shtat { get; set; }
|
|
public DbSet<Rabotnik> Rabotniky { get; set; }
|
|
public DbSet<Chel> Chely { get; set; }
|
|
public DbSet<TypeStaj> TypeStajy { get; set; }
|
|
public DbSet<RabotnikTypeStaj> RabotnikTypeStajy { get; set; }
|
|
public DbSet<Child> Childy { get; set; }
|
|
public DbSet<Learn> Learny { get; set; }
|
|
public DbSet<CorrStaj> CorrStajy { get; set; }
|
|
public DbSet<Free> Freey { get; set; }
|
|
public DbSet<Access> Accessy { get; set; }
|
|
public DbSet<User> Usery { get; set; }
|
|
|
|
public MainDB()
|
|
{
|
|
Database.EnsureCreated();
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseSqlite("Data Source=" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Diplom_O.db;");
|
|
}
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder) { }
|
|
|
|
}
|
|
|
|
public static partial class FuncDB
|
|
{
|
|
public static void InitDB()
|
|
{
|
|
if (UserGetByLogin("Admin") != null)
|
|
return;
|
|
var user = new User()
|
|
{
|
|
Login = "Admin",
|
|
Pass = "Admin",
|
|
Hide = true,
|
|
Default = 7
|
|
};
|
|
UserAdd(user);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|