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(); }
public UserStore(Models.AppDbContext dbContext) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } users = dbContext.GetCollection <TUser>(); }
public RoleStore(Models.AppDbContext dbContext) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } roles = dbContext.GetCollection <TRole>(); }
public ArticleController(Models.AppDbContext context, IWebHostEnvironment webHost, UserManager <ApplicationUser> userManager) { _db = context; _webHost = webHost; _userManager = userManager; HasCategory().Wait(); }
public AuthenticationModel(Models.AppDbContext context) { _context = context; }
public HomeController(Models.AppDbContext context, SignInManager <ApplicationUser> signManager) { _db = context; _signManager = signManager; }
public CreateModel(Models.AppDbContext context) { _context = context; }
public BugController(Models.AppDbContext context, UserManager <ApplicationUser> userManager) { _db = context; _userManager = userManager; }