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_B.DB { public class MainDB : DbContext { public DbSet Users { get; set; } public DbSet Statusy { get; set; } public DbSet Dogovory { get; set; } public DbSet Izdeliya { get; set; } public DbSet DogIzds { get; set; } public DbSet Zakazchiki { get; set; } public DbSet Documenty { get; set; } public DbSet Izvescheniya { get; set; } public DbSet DocIzvs { get; set; } public DbSet Postavki { get; set; } public DbSet Platejy { get; set; } public DbSet DogDocs { get; set; } public MainDB() { //Database.Migrate(); Database.EnsureCreated(); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlite("Data Source=" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Diplom_B.db;"); } protected override void OnModelCreating(ModelBuilder modelBuilder) { } } public class User { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } public string Pass { get; set; } public int Dog { get; set; } public int Doc { get; set; } public int Izv { get; set; } public int Post { get; set; } public int Izd { get; set; } public int Zak { get; set; } public int Set { get; set; } public int Default { get; set; } } public class Status { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Stat { get; set; } } public class Dogovor { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string DogNum { get; set; } public List DogIzds { get; set; } [ForeignKey("Zakazchik")] public int ZakazchikId { get; set; } public Zakazchik Zakazchik { get; set; } public DateTime DataPostavky { get; set; } public string Garantiy { get; set; } public string PrikazZapusk { get; set; } public List Platejy { get; set; } public string Primechanie { get; set; } public List DogDocs { get; set; } public List Postavky { get; set; } } public class Izdelie { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } public string DecNum { get; set; } public string Shifr { get; set; } public string Litera { get; set; } public double Cena { get; set; } public int OtdelRazrab { get; set; } public string Ved { get; set; } public string GlavKonstr { get; set; } public List Postavky { get; set; } public List DogIzds { get; set; } } public class DogIzd { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public int Kolvo { get; set; } [ForeignKey("Dogovor")] public int DogovorId { get; set; } public Dogovor Dogovor { get; set; } [ForeignKey("Izdelie")] public int IzdelieId { get; set; } public Izdelie Izdelie { get; set; } } public class Zakazchik { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } public string Adress { get; set; } public string Phone { get; set; } public string Email { get; set; } public List Dogovory { get; set; } } public class Document { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string InvNum { get; set; } public string DecNum { get; set; } public string Name { get; set; } public string FileName { get; set; } public byte[] FileStruct { get; set; } public string Primechanie { get; set; } public List DocIzvs { get; set; } public List DogDocs { get; set; } } public class Izveschenie { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string IzvNum { get; set; } public int InvNum { get; set; } public int IzmNum { get; set; } public string UkazZad { get; set; } public string UkazVnedr { get; set; } public string FileName { get; set; } public byte[] FileStruct { get; set; } public List DocIzvs { get; set; } } public class DocIzv { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [ForeignKey("Document")] public int DocumentId { get; set; } public Document Document { get; set; } [ForeignKey("Izveschenie")] public int IzveschenieId { get; set; } public Izveschenie Izveschenie { get; set; } } public class Postavka { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string ZavNum { get; set; } [ForeignKey("Dogovor")] public int? DogovorId { get; set; } public Dogovor Dogovor { get; set; } [ForeignKey("Status")] public int StatusId { get; set; } public Status Status { get; set; } public DateTime DataPostavki { get; set; } public string Primechanie { get; set; } [ForeignKey("Izdelie")] public int? IzdelieId { get; set; } public Izdelie Izdelie { get; set; } } public class Platej { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public double Summa { get; set; } [ForeignKey("Dogovor")] public int DogovorId { get; set; } public Dogovor Dogovor { get; set; } } public class DogDoc { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [ForeignKey("Dogovor")] public int DogovorId { get; set; } public Dogovor Dogovor { get; set; } [ForeignKey("Document")] public int DocumentId { get; set; } public Document Document { get; set; } } }