Пример #1
0
        public static async Task Initialize(IServiceProvider serviceProvider, string testUserPw)
        {
            using (var context = new WebApp2IdentityDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <WebApp2IdentityDbContext> >()))
            {
                var adminID = EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                await EnsureRole(serviceProvider, adminID, Constants.ContactAdministratorsRole);

                var managerID = EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                await EnsureRole(serviceProvider, managerID, Constants.ContactManagersRole);

                SeedDB(context, adminID);
            }
        }
Пример #2
0
 public DeleteModel(WebApp2.Areas.Identity.Data.WebApp2IdentityDbContext context)
 {
     _context = context;
 }
Пример #3
0
        public static void SeedDB(WebApp2IdentityDbContext context, string adminID)
        {
            if (context.Contact.Any())
            {
                return;   // DB has been seeded
            }

            context.Contact.AddRange(
                new Contact
            {
                Name    = "Debra Garcia",
                Address = "1234 Main St",
                City    = "Redmond",
                State   = "WA",
                Zip     = "10999",
                Email   = "*****@*****.**",
                Status  = ContactStatus.Approved,
                OwnerID = adminID
            },
                new Contact
            {
                Name    = "Thorsten Weinrich",
                Address = "5678 1st Ave W",
                City    = "Redmond",
                State   = "WA",
                Zip     = "10999",
                Email   = "*****@*****.**",
                Status  = ContactStatus.Approved,
                OwnerID = adminID
            },
                new Contact
            {
                Name    = "Yuhong Li",
                Address = "9012 State st",
                City    = "Redmond",
                State   = "WA",
                Zip     = "10999",
                Email   = "*****@*****.**",
                Status  = ContactStatus.Approved,
                OwnerID = adminID
            },
                new Contact
            {
                Name    = "Jon Orton",
                Address = "3456 Maple St",
                City    = "Redmond",
                State   = "WA",
                Zip     = "10999",
                Email   = "*****@*****.**",
                Status  = ContactStatus.Submitted,
                OwnerID = adminID
            },
                new Contact
            {
                Name    = "Diliana Alexieva-Bosseva",
                Address = "7890 2nd Ave E",
                City    = "Redmond",
                State   = "WA",
                Zip     = "10999",
                Email   = "*****@*****.**",
                Status  = ContactStatus.Rejected,
                OwnerID = adminID
            }
                );
            context.SaveChanges();
        }