protected override void Up(MigrationBuilder migrationBuilder)
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var dbContext   = new SampleDataBaseContext(new DbContextOptions <SampleDataBaseContext>());
                var userStore   = new CustomUserStore(dbContext);
                var userManager = new UserManager <User>(userStore, null, null, null, null, null, null, null, null);
                var user        = new User
                {
                    UserName           = "******",
                    NormalizedUserName = "******",
                    Email                = "*****@*****.**",
                    NormalizedEmail      = "*****@*****.**",
                    PhoneNumber          = "+111111111111",
                    EmailConfirmed       = true,
                    PhoneNumberConfirmed = true,
                    SecurityStamp        = Guid.NewGuid().ToString("D"),
                    LockoutEnabled       = true,
                };
                string password = "******";
                //var result = userManager.CreateAsync(user, password).Result;
                var hashed = new PasswordHasher <User>().HashPassword(user, password);
                user.PasswordHash = hashed;
                var result = userStore.CreateAsync(user).Result;
                userStore.AddToRoleAsync(user, RoleEnum.Admin.ToString()).Wait();

                dbContext.SaveChanges();
                scope.Complete();
            }
        }
Beispiel #2
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var dbContext   = new SampleDataBaseContext(new DbContextOptions <SampleDataBaseContext>());
                var userStore   = new CustomUserStore(dbContext);
                var userManager = new UserManager <User>(userStore, null, null, null, null, null, null, null, null);
                var user        = userManager.FindByNameAsync("Sarah").Result;
                var claims      = new List <Claim>
                {
                    new Claim(ClaimTypes.System, "auth;crud;cqrs"),
                };
                userManager.AddClaimsAsync(user, claims).Wait();

                dbContext.SaveChanges();
                scope.Complete();
            }
        }
Beispiel #3
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var dbContext   = new SampleDataBaseContext(new DbContextOptions <SampleDataBaseContext>());
                var userStore   = new CustomUserStore(dbContext);
                var userManager = new UserManager <User>(userStore, null, null, null, null, null, null, null, null);
                var user        = new User
                {
                    UserName           = "******",
                    NormalizedUserName = "******",
                    Email                = "*****@*****.**",
                    NormalizedEmail      = "*****@*****.**",
                    PhoneNumber          = null,
                    EmailConfirmed       = true,
                    PhoneNumberConfirmed = false,
                    SecurityStamp        = Guid.NewGuid().ToString("D"),
                    LockoutEnabled       = true,
                };
                string password = "******";
                var    hashed   = new PasswordHasher <User>().HashPassword(user, password);
                user.PasswordHash = hashed;
                var result = userStore.CreateAsync(user).Result;
                userStore.AddToRoleAsync(user, RoleEnum.Member.ToString()).Wait();
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
                    new Claim(ClaimTypes.Name, user.UserName),
                    new Claim(ClaimTypes.System, "crud"),
                };
                userManager.AddClaimsAsync(user, claims).Wait();

                dbContext.SaveChanges();
                scope.Complete();
            }
        }
Beispiel #4
0
 public UnitOfWork(SampleDataBaseContext dbContext)
 {
     this._dbContext = dbContext;
 }
Beispiel #5
0
 public ReadOnlyRepository(SampleDataBaseContext dbContext)
 {
     this.MyDBContext = dbContext;
 }
 public BankRepository(SampleDataBaseContext dbContext)
     : base(dbContext)
 {
 }
Beispiel #7
0
 public CountryRepository(SampleDataBaseContext dbContext)
     : base(dbContext)
 {
 }