예제 #1
0
        public async Task Test([FromServices] Models.AppDbContext context)
        {
            //为了测试方便,这里直接在内存里存一个user对象并登陆
            var user = new ApplicationUser()
            {
                UserName = "******",
                Email    = "*****@*****.**"
            };
            await _userManager.CreateAsync(user);

            await _userManager.AddToRoleAsync(user, "Root");

            await _signInManager.SignInAsync(user, false);

            //在这里添加测试数据
            Category[] categories = new Category[3]
            {
                new Category {
                    Id = Guid.NewGuid(), CategoryName = "intro"
                },
                new Category {
                    Id = Guid.NewGuid(), CategoryName = "activity"
                },
                new Category {
                    Id = Guid.NewGuid(), CategoryName = "others"
                },
            };

            context.Categories.AddRange(categories);
            context.SaveChanges();
        }
예제 #2
0
        public UserStore(Models.AppDbContext dbContext)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            users = dbContext.GetCollection <TUser>();
        }
예제 #3
0
        public RoleStore(Models.AppDbContext dbContext)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            roles = dbContext.GetCollection <TRole>();
        }
예제 #4
0
 public ArticleController(Models.AppDbContext context,
                          IWebHostEnvironment webHost,
                          UserManager <ApplicationUser> userManager)
 {
     _db          = context;
     _webHost     = webHost;
     _userManager = userManager;
     HasCategory().Wait();
 }
예제 #5
0
 public AuthenticationModel(Models.AppDbContext context)
 {
     _context = context;
 }
예제 #6
0
 public HomeController(Models.AppDbContext context, SignInManager <ApplicationUser> signManager)
 {
     _db          = context;
     _signManager = signManager;
 }
예제 #7
0
 public CreateModel(Models.AppDbContext context)
 {
     _context = context;
 }
예제 #8
0
 public BugController(Models.AppDbContext context, UserManager <ApplicationUser> userManager)
 {
     _db          = context;
     _userManager = userManager;
 }