Entities + Migration
This commit is contained in:
@@ -6,7 +6,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.RequestContext;
|
||||
using WorkFlowCheck.Common.Security;
|
||||
using WorkFlowCheck.DL.Configurations;
|
||||
using WorkFlowCheck.DL.Entities;
|
||||
using WorkFlowCheck.DL.Extensions;
|
||||
using WorkFlowCheck.DL.Interfaces;
|
||||
|
||||
@@ -55,8 +57,10 @@ namespace WorkFlowCheck.DL
|
||||
modelBuilder.ApplyConfiguration(new RoleTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new UsersCheckListTemplateHeaderTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new UserTypeConfiguration());
|
||||
|
||||
|
||||
modelBuilder.RegisterSoftDeleteQueryFilters();
|
||||
|
||||
SeedInit(modelBuilder);
|
||||
}
|
||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
@@ -111,5 +115,39 @@ namespace WorkFlowCheck.DL
|
||||
entry.State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
|
||||
private void SeedInit(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>().HasData(
|
||||
new User
|
||||
{
|
||||
Id = 1,
|
||||
Email = "admin@nuvolar.hu",
|
||||
FirstName = "Administrator",
|
||||
LastName = "System",
|
||||
IsDeleted = false,
|
||||
UserName = "admin",
|
||||
PasswordHash = PasswordHasher.HashPassword("111111"),
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CreatedBy = "System",
|
||||
LastModAt = DateTime.UtcNow,
|
||||
LastModBy = "System",
|
||||
},
|
||||
new User
|
||||
{
|
||||
Id = 2,
|
||||
Email = "user@nuvolar.hu",
|
||||
FirstName = "User",
|
||||
LastName = "System",
|
||||
IsDeleted = false,
|
||||
UserName = "user",
|
||||
PasswordHash = PasswordHasher.HashPassword("222222"),
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CreatedBy = "System",
|
||||
LastModAt = DateTime.UtcNow,
|
||||
LastModBy = "System",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user