2021-07-21 16:57:47 +05:00
|
|
|
|
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; }
|
2024-09-20 08:53:52 +05:00
|
|
|
|
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; }
|
2021-07-21 16:57:47 +05:00
|
|
|
|
|
|
|
|
|
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) { }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-20 08:53:52 +05:00
|
|
|
|
public static partial class FuncDB
|
2021-07-21 16:57:47 +05:00
|
|
|
|
{
|
2024-09-20 08:53:52 +05:00
|
|
|
|
public static void InitDB()
|
|
|
|
|
{
|
|
|
|
|
if (UserGetByLogin("Admin") != null)
|
|
|
|
|
return;
|
|
|
|
|
var user = new User()
|
|
|
|
|
{
|
|
|
|
|
Login = "Admin",
|
|
|
|
|
Pass = "Admin",
|
|
|
|
|
Hide = true,
|
|
|
|
|
Default = 7
|
|
|
|
|
};
|
|
|
|
|
UserAdd(user);
|
|
|
|
|
}
|
2021-07-25 09:43:21 +05:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 16:57:47 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-20 08:53:52 +05:00
|
|
|
|
|
|
|
|
|
}
|
2021-07-21 16:57:47 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|