public ModulesController(ELearningPlatformContext context)
 {
     _context     = context;
     _coursesData = new CoursesData(_context);
     _usersData   = new UsersData(_context);
     _moduleData  = new ModuleData(_context);
 }
Exemplo n.º 2
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new ELearningPlatformContext(
                serviceProvider.GetRequiredService <
                    DbContextOptions <ELearningPlatformContext> >()))
     {
         // Look for any tokens.
         if (!context.Role.Any())
         {
             context.Role.AddRange(
                 new Role
             {
                 Label = "Guest"
             },
                 new Role
             {
                 Label = "Student"
             },
                 new Role
             {
                 Label = "Instructor"
             }
                 );
             context.SaveChanges();
         }
         if (!context.User.Any())
         {
             context.User.AddRange(
                 new User
             {
                 Email       = "*****@*****.**", //account specially created as default user
                 Username    = "******",
                 IdCode      = 3,
                 IsConfirmed = true,
                 Password    = "******"
             }
                 );
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 3
0
        public AccountController(ILogger <HomeController> logger, ELearningPlatformContext context, EmailConfiguration emailConfiguration,
                                 UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager)
        {
            _logger            = logger;
            _context           = context;
            this.userManager   = userManager;
            this.signInManager = signInManager;
            usersData          = new UsersData(_context);
            _emailSender       = new EmailSender(emailConfiguration);


            if (_context.User.Count() == 0)
            {
                // Create a new User if collection is empty,
                // which means you can't delete all users.
                _context.User.Add(new User {
                    Email = "*****@*****.**", IsConfirmed = true, IdCode = 3
                });
                _context.SaveChanges();
            }
            usersData.GetAllUser();
        }
Exemplo n.º 4
0
 public HomeController(ELearningPlatformContext context)
 {
     _context    = context;
     usersData   = new UsersData(_context);
     coursesData = new CoursesData(_context);
 }
 public SubjectsController(ELearningPlatformContext context)
 {
     _context     = context;
     _subjectData = new SubjectData(_context);
 }