Files
parr_api/PARR.DAL/Context/DataContext.cs

63 lines
2.9 KiB
C#
Raw Normal View History

2023-05-17 16:30:13 +10:00
using Microsoft.EntityFrameworkCore;
2023-06-16 15:00:11 +10:00
using PARR.DAL.Contracts;
2023-05-17 16:30:13 +10:00
using PARR.DAL.Models;
namespace PARR.DAL.Context
{
internal class DataContext : DbContext
{
public DataContext(DbContextOptions<DataContext> options) : base(options) { }
2023-05-19 15:15:52 +10:00
public DbSet<JobType> JobTypes { get; set; }
public DbSet<JobCategory> JobCategories { get; set; }
public DbSet<JobMode> JobModes { get; set; }
public DbSet<JobStatus> JobStatuses { get; set; }
public DbSet<Host> Hosts { get; set; }
public DbSet<Job> Jobs { get; set; }
public DbSet<JobJournal> JobJournals { get; set; }
2023-06-13 13:57:55 +10:00
public DbSet<Application> Applications { get; set; }
public DbSet<ApplicationType> ApplicationTypes { get; set; }
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
2023-06-20 12:29:58 +10:00
//public DbSet<Scheduler> Schedulers { get; set; }
2023-06-13 13:57:55 +10:00
2023-06-16 15:00:11 +10:00
//todo init application type+check migrations
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var dateCreated = new DateTimeOffset(2023, 05, 01, 0, 0, 0, new TimeSpan(0));
modelBuilder.Entity<JobMode>(f =>
{
f.HasData(
new() { Id = new Guid("FBA4202C-5BAD-49C4-B076-D1CA6E1FB158"), DateCreated = dateCreated, DateModified = null, Name = "auto" },
new() { Id = new Guid("7516B952-510D-4AAA-971C-A14B184FC1D5"), DateCreated = dateCreated, DateModified = null, Name = "manual" }
);
});
2023-06-20 12:29:58 +10:00
modelBuilder.Entity<JobStatus>(f =>
{
f.HasData(
new() { Id = new Guid("EDEF6DC3-ADAD-4C77-8AD1-63BB9052355A"), DateCreated = dateCreated, DateModified = null, Name = "started", Description = "Задание запущено" },
new() { Id = new Guid("7B945EB6-D885-4570-AFF5-8866F1F75FF2"), DateCreated = dateCreated, DateModified = null, Name = "finished", Description = "Задание выполнено" }
);
});
2023-06-16 15:00:11 +10:00
modelBuilder.Entity<ApplicationType>(f =>
{
f.HasData(
new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Поле СП xml АИХ ИТ" },
new() { Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.OS.ToString(), Description = "Поле ОС xml АИХ ИТ" },
new() { Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.DB.ToString(), Description = "Поле СУБД xml АИХ ИТ" }
);
});
}
2023-05-17 16:30:13 +10:00
}
}