public AccountController( UserManager <User> userManager, SignInManager <User> signInManager, QuizAppContext ctx, IConfiguration config, ILogger <AccountController> logger) { _userManager = userManager; _signInManager = signInManager; _ctx = ctx; _config = config; _logger = logger; }
public static void Init(IServiceProvider service) { var ctx = new QuizAppContext(service.GetRequiredService <DbContextOptions <QuizAppContext> >()); ctx.Database.EnsureDeleted(); ctx.Database.Migrate(); for (int i = 1; i <= 20; i++) { ctx.Questions.Add(new Question { QuestionString = $"Question {i}", Answer = $"Answer {i}" }); } var userManager = service.GetRequiredService <UserManager <User> >(); var passwordHasher = new PasswordHasher <User>(); service.GetService <RoleManager <IdentityRole <int> > >().CreateAsync(new UserRole { Name = "administrator", NormalizedName = "administrator" }).Wait(); var user = new User { UserName = "******" }; user.PasswordHash = passwordHasher.HashPassword(user, "User"); var admin = new User { UserName = "******" }; admin.PasswordHash = passwordHasher.HashPassword(admin, "Admin"); var rdm = new Random(); user.HiScore = new HiScore { SubmitDate = DateTime.UtcNow.AddMinutes(rdm.Next(21)) }; admin.HiScore = new HiScore { SubmitDate = DateTime.UtcNow.AddMinutes(rdm.Next(21)) }; userManager.CreateAsync(user).Wait(); userManager.CreateAsync(admin).Wait(); userManager.AddToRoleAsync(admin, "administrator").Wait(); ctx.SaveChanges(); ctx.Dispose(); }
public SubjectController() { _EntityRepository = new QuizAppContext(); }
public QuestionService(QuizAppContext context) { _db = context; }
public DifficultyRepo(QuizAppContext context) { this.context = context; }
public HomeController(ILogger <HomeController> logger, QuizAppContext context) { _logger = logger; _context = context; }
public ResultService(QuizAppContext context) { _db = context; }
public QuestionsController(IUnitOfWork uow, QuizAppContext context) { this._uow = uow; this._context = context; }
public QuizService(QuizAppContext context) { _db = context; }
public QuestionsController(QuizAppContext context, ILogger <QuestionsController> logger) { _context = context; _logger = logger; }
public QuestionRepository(QuizAppContext db) { this.db = db; }
public AnswerRepo(QuizAppContext context) { this.context = context; }
public QuestionsController(QuizAppContext context) { _context = context; }
public QuizItemsController(QuizAppContext ctx, ILogger <QuizItemsController> logger) { _ctx = ctx; _logger = logger; }
public QuizesController(QuizAppContext context) { _context = context; }
public AdminController(QuizAppContext context) { _context = context; }
public QuizRepo(QuizAppContext context) { this.context = context; }
public UnitOfWork(QuizAppContext _db) { db = _db; }
public HiScoresController(QuizAppContext context, ILogger <HiScoresController> logger) { _context = context; _logger = logger; }
public LoginService(QuizAppContext db) { _db = db; }