mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using CartriX.Shared.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CartriX.Shared.Classes
|
|
{
|
|
public class AppDbContext : DbContext
|
|
{
|
|
public AppDbContext(DbContextOptions options) : base(options) { }
|
|
|
|
public DbSet<Printer> Printers { get; set; }
|
|
public DbSet<PrinterModel> PrinterModels { get; set; }
|
|
public DbSet<Location> Locations { get; set; }
|
|
public DbSet<Cartridge> Cartridges { get; set; }
|
|
public DbSet<CartridgeModel> CartridgeModels { get; set; }
|
|
public DbSet<PrintType> PrintTypes { get; set; }
|
|
public DbSet<CartridgeStatus> CartridgeStatuses { get; set; }
|
|
public DbSet<LogPrinters> LogPrinters { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
|
modelBuilder.Entity<Location>().HasIndex(l => l.name).IsUnique();
|
|
|
|
modelBuilder.Entity<PrintType>().HasData(
|
|
new PrintType { id = 1, name = "Laser" },
|
|
new PrintType { id = 2, name = "Inkjet" }
|
|
);
|
|
modelBuilder.Entity<CartridgeStatus>().HasData(
|
|
new CartridgeStatus { id = 1, name = "Installed" },
|
|
new CartridgeStatus { id = 2, name = "InStock" },
|
|
new CartridgeStatus { id = 3, name = "WriteOff" },
|
|
new CartridgeStatus { id = 4, name = "Refilling" },
|
|
new CartridgeStatus { id = 5, name = "InlineRefilling" },
|
|
new CartridgeStatus { id = 6, name = "UnderRepair" }
|
|
);
|
|
modelBuilder.Entity<Printer>().Property(p => p.oidForQueryCountPrintedAllTime).HasDefaultValue("1.3.6.1.2.1.43.10.2.1.4.1.1");
|
|
|
|
}
|
|
}
|
|
} |