Пример #1
0
        private async Task SeedUsers()
        {
            var founder = await _userMgr.FindByNameAsync("yaduolhotmailcom");

            if (founder == null)
            {
                founder = await ApplicationUser.CreateAsync(
                    _userMgr,
                    "*****@*****.**",
                    "Course123$",
                    "Founder",
                    "Co",
                    "default.jpg",
                    new List <string>() { ApplicationPolicies.DefaultRoles.Root, ApplicationPolicies.DefaultRoles.Staff }
                    );

                founder.EmailConfirmed = true;
                var adminModel = Administrator.Create();
                founder.Administrator = adminModel;
                founder.Administrator.Activate();
                await _context.SaveChangesAsync();
            }

            var tutor = await _userMgr.FindByNameAsync("yaduolmailinatorcom");

            if (tutor == null)
            {
                tutor = await ApplicationUser.CreateAsync(
                    _userMgr,
                    "*****@*****.**",
                    "Course123$",
                    "Tutor",
                    "Co",
                    "default.jpg",
                    new List <string>() { ApplicationPolicies.DefaultRoles.Tutor }
                    );

                tutor.EmailConfirmed = true;
                tutor.Tutor          = Tutor.Create("Hello! I am the first tutor.", 0.5);
                tutor.Tutor.Apply();
                tutor.Tutor.Approve(founder, "default approved");
                await _context.SaveChangesAsync();
            }

            var tutor2 = await _userMgr.FindByNameAsync("tutormailinatorcom");

            if (tutor2 == null)
            {
                tutor2 = await ApplicationUser.CreateAsync(
                    _userMgr,
                    "*****@*****.**",
                    "Course123$",
                    "Tutor2",
                    "Co2",
                    "default.jpg",
                    new List <string>() { ApplicationPolicies.DefaultRoles.Tutor }
                    );

                tutor2.EmailConfirmed = true;
                tutor2.Tutor          = Tutor.Create("Hello! I am the first tutor.", 0.5);
                tutor2.Tutor.Apply();
                tutor2.Tutor.Approve(founder, "default approved");
                await _context.SaveChangesAsync();
            }

            var student = await _userMgr.FindByNameAsync("aliumailinatorcom");

            if (student == null)
            {
                student = await ApplicationUser.CreateAsync(
                    _userMgr,
                    "*****@*****.**",
                    "Course123$",
                    "Student",
                    "Co",
                    "default.jpg"
                    );

                student.EmailConfirmed = true;
                await _context.SaveChangesAsync();
            }
        }