public static async Task Seed(IAppUserService appUserService, IAppUserRoleService appUserRoleService, IAppRoleService appRoleService) { var adminRole = await appRoleService.FindByNameAsync(RoleInfo.Admin); if (adminRole == null) { await appRoleService.AddAsync(new Entities.Concrete.AppRole { Name = RoleInfo.Admin }); } var memberRole = await appRoleService.FindByNameAsync(RoleInfo.Member); if (memberRole == null) { await appRoleService.AddAsync(new Entities.Concrete.AppRole { Name = RoleInfo.Member }); } var adminUser = await appUserService.FindByEmail("*****@*****.**"); if (adminUser == null) { string password = BCrypt.Net.BCrypt.HashPassword("1"); await appUserService.AddAsync(new Entities.Concrete.AppUser { Name = "Admin Test", Password = password, Email = "*****@*****.**", ImagePath = "default.jpg", UserName = "******", Surname = "Admin Surname", }); var role = await appRoleService.FindByNameAsync(RoleInfo.Admin); var admin = await appUserService.FindByEmail("*****@*****.**"); await appUserRoleService.AddAsync(new Entities.Concrete.AppUserRole { AppUserId = admin.Id, AppRoleId = role.Id }); } }
public static async Task Seed(IAppUserService appUserService, IAppUserRoleService appUserRoleService, IAppRoleService appRoleService) { var adminRole = await appRoleService.FindByNameAsync(RoleInfo.Admin); if (adminRole == null) { await appRoleService.AddAsync(new AppRole { Name = RoleInfo.Admin }); } var memberRole = await appRoleService.FindByNameAsync(RoleInfo.Member); if (memberRole == null) { await appRoleService.AddAsync(new AppRole { Name = RoleInfo.Member }); } var adminUser = await appUserService.FindByUserNameAsync("emre"); if (adminUser == null) { await appUserService.AddAsync(new AppUser { FullName = "emre yüksek", UserName = "******", Password = "******" }); var role = await appRoleService.FindByNameAsync(RoleInfo.Admin); var admin = await appUserService.FindByUserNameAsync("emre"); await appUserRoleService.AddAsync(new AppUserRole { AppUserId = admin.Id, AppRoleId = role.Id }); } }
public static async Task Seed(IAppUserService appUserService, IAppUserRoleService appUserRoleService, IAppRoleService appRoleService) { var adminRole = await appRoleService.FindByName(RoleInfo.Admin); if (adminRole == null) { await appRoleService.AddAsync(new Entities.Concrete.AppRole { Name = RoleInfo.Admin }); } var memberRole = await appRoleService.FindByName(RoleInfo.Member); if (adminRole == null) { await appRoleService.AddAsync(new Entities.Concrete.AppRole { Name = RoleInfo.Member }); } var adminUser = await appUserService.FindByUserName("Uzay"); if (adminUser == null) { await appUserService.AddAsync(new AppUser { FullName = "Uzay KAHRAMAN", UserName = "******", Password = "******" }); var role = await appRoleService.FindByName(RoleInfo.Admin); var admin = await appUserService.FindByUserName("Uzay"); await appUserRoleService.AddAsync(new AppUserRole { AppUserId = admin.Id, AppRoleId = role.Id }); } }