Exemplo n.º 1
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new CCTV_AppContext(
                serviceProvider.GetRequiredService <DbContextOptions <CCTV_AppContext> >()))
     {
         if (context.Users.Any())
         {
             return;
         }
         var passwordHasher = new PasswordHasher <string>();
         if (!context.Users.Any())
         {
             context.Users.AddRange(
                 new User
             {
                 FirstName       = "Admin",
                 LastName        = "Admin",
                 Username        = "******",
                 Password        = passwordHasher.HashPassword(null, "admin"),
                 ConfirmPassword = passwordHasher.HashPassword(null, "admin"),
                 Email           = "*****@*****.**",
                 Role            = "admin",
                 MobileNo        = "000000000000",
                 Location        = "System",
                 CreatedBy       = "System",
                 CreatedDate     = DateTime.Now
             }
                 );
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 2
0
 public AuditModel(CCTV_App.Models.CCTV_AppContext context, IHttpContextAccessor httpContextAccessor)
 {
     _context             = context;
     _httpContextAccessor = httpContextAccessor;
 }