Files
parr_api/PARR.DAL/Context/DataContext.cs
Mikhail Kuznetsov 9c19e2fb91 JobStatus init
2023-06-20 12:29:58 +10:00

63 lines
2.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.EntityFrameworkCore;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
namespace PARR.DAL.Context
{
internal class DataContext : DbContext
{
public DataContext(DbContextOptions<DataContext> options) : base(options) { }
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; }
public DbSet<Application> Applications { get; set; }
public DbSet<ApplicationType> ApplicationTypes { get; set; }
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
//public DbSet<Scheduler> Schedulers { get; set; }
//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" }
);
});
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 = "Задание выполнено" }
);
});
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 АИХ ИТ" }
);
});
}
}
}