Ejemplo n.º 1
0
        public static async Task Initialize(IServiceProvider serviceProvider, string testUserPw)
        {
            using (var context = new ELIMS_MVCContext(
                       serviceProvider.GetRequiredService <DbContextOptions <ELIMS_MVCContext> >()))
            {
                // For sample purposes we are seeding 2 users both with the same password.
                // The password is set with the following command:
                // dotnet user-secrets set SeedUserPW <pw>
                // The admin user can do anything

                // Create admin user
                var adminid = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                await EnsureRole(serviceProvider, adminid, Constants.ELIMSAdministratorsRole);

                // Created manager
                var managerid = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                await EnsureRole(serviceProvider, managerid, Constants.ELIMSManagersRole);

                // Created regular user
                var userid = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                await EnsureRole(serviceProvider, userid, Constants.ELIMSUsersRole);

                SeedDB(context, adminid, managerid, userid);
            }
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ELIMS_MVCContext dbContext)
        {
            //dbContext.Database.EnsureCreated();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();
            //app.UseIdentity();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 3
0
 public DashboardController(ELIMS_MVCContext context, UserManager <ApplicationUser> userManager, IAuthorizationService authorizationService)
 {
     _context              = context;
     _userManager          = userManager;
     _authorizationService = authorizationService;
 }
Ejemplo n.º 4
0
        //#region snippet1
        public static void SeedDB(ELIMS_MVCContext context, string adminid, string managerid, string userid)
        {
            if (context.Request.Any())
            {
                return;   // DB has been seeded
            }

            // Some sample requests to seed the database with
            //context.Request.AddRange(
            //#region snipped_Request
            //    new Request
            //    {
            //        FirstName = "Bruce",
            //        LastName = "Wayne",
            //        UserId = "1234567",
            //        NAUEmail = "*****@*****.**",
            //        ProjectName = "OMAC",
            //        ProjectObjective = "Observational Metahuman Activity Construct",
            //        ContactName = "Jack Kirby",
            //        ContactID = "135790",
            //        Funding = "N/A",
            //        SponsorName = "Brother Eye",
            //        SponsorPhone = "123-456-7890",
            //        SponsorEmail = "*****@*****.**",
            //        Chemicals = "N/A",
            //        MeetingTimes = "N/A",
            //        GroupMembers = "Buddy Blank, Alexander Luthor Jr., Max Lord",
            //        ProjectFile = "",
            //        Status = RequestStatus.Pending,
            //        OwnerID = adminid
            //    },
            //#endregion
            //#endregion

            //   new Request
            //   {
            //       FirstName = "Diana",
            //       LastName = "Prince",
            //       UserId = "2468102",
            //       NAUEmail = "*****@*****.**",
            //       ProjectName = "Themyscira",
            //       ProjectObjective = "Babysit these baby metahumans",
            //       ContactName = "Patty Jenkins",
            //       ContactID = "135210",
            //       Funding = "DC Comics",
            //       SponsorName = "William Moulton Martson",
            //       SponsorPhone = "123-456-7890",
            //       SponsorEmail = "*****@*****.**",
            //       Chemicals = "N/A",
            //       MeetingTimes = "N/A",
            //       GroupMembers = "Donna Troy, Cassie Sandsmark, Elizabeth Moulton, Olive Bryne",
            //       ProjectFile = "",
            //       Status = RequestStatus.Approved,
            //       OwnerID = managerid
            //   },
            //   new Request
            //   {
            //       FirstName = "Clark",
            //       LastName = "Kent",
            //       UserId = "9765432",
            //       NAUEmail = "*****@*****.**",
            //       ProjectName = "Krypton",
            //       ProjectObjective = "Avoid parental responsibility",
            //       ContactName = "Connor Kent",
            //       ContactID = "135790",
            //       Funding = "N/A",
            //       SponsorName = "Lex Luthor",
            //       SponsorPhone = "123-456-7890",
            //       SponsorEmail = "*****@*****.**",
            //       Chemicals = "N/A",
            //       MeetingTimes = "N/A",
            //       GroupMembers = "Buddy Blank, Alexander Luthor Jr., Max Lord",
            //       ProjectFile = "",
            //       Status = RequestStatus.Approved,
            //       OwnerID = userid
            //   },
            //   new Request
            //   {
            //       FirstName = "Barry",
            //       LastName = "Allen",
            //       UserId = "7654321",
            //       NAUEmail = "*****@*****.**",
            //       ProjectName = "Gideon",
            //       ProjectObjective = "Artificial intelligence",
            //       ContactName = "Iris West",
            //       ContactID = "0000000",
            //       Funding = "Questionable",
            //       SponsorName = "Harrison Wells",
            //       SponsorPhone = "000-000-0000",
            //       SponsorEmail = "*****@*****.**",
            //       Chemicals = "Who knows",
            //       MeetingTimes = "Tuesdays at 8pm",
            //       GroupMembers = "Cisco Ramon, Caitlin Snow, Joe West, Iris West",
            //       ProjectFile = "",
            //       Status = RequestStatus.Denied,
            //       OwnerID = userid
            //}
            //);
            context.SaveChanges();
        }
Ejemplo n.º 5
0
 public RequestController(ELIMS_MVCContext context, IAuthorizationService authorizationService, UserManager <ApplicationUser> userManager)
 {
     _context = context;
     _authorizationService = authorizationService;
     _userManager          = userManager;
 }
Ejemplo n.º 6
0
 public BioRaftsController(ELIMS_MVCContext context)
 {
     _context = context;
 }
Ejemplo n.º 7
0
 public LabSafetyController(ELIMS_MVCContext context)
 {
     _context = context;
 }
Ejemplo n.º 8
0
 public AccountController(SignInManager <ApplicationUser> signInManager, ILogger <AccountController> logger, ELIMS_MVCContext context)
 {
     _signInManager = signInManager;
     _logger        = logger;
     _context       = context;
 }