예제 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using var ctx = new OctoCodesContext(serviceProvider.GetRequiredService <DbContextOptions <OctoCodesContext> >());

            if (ctx.Users.Any())
            {
                return;
            }

            ctx.Users.Add(
                new User
            {
                Username = "******",
                Password = AdminController.EncryptPassword("Password1")
            }
                );
            ctx.SaveChanges();
        }
예제 #2
0
 public ArticleController(OctoCodesContext ctx)
 {
     this.ctx = ctx;
 }
예제 #3
0
 public AdminController(OctoCodesContext ctx, IWebHostEnvironment webHostEnvironment)
 {
     this.ctx = ctx;
     this.webHostEnvironment = webHostEnvironment;
 }