public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; await ensureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); ApplicationUser applicationUser = new ApplicationUser { UserName = "******", FullName = "Віталій Мураль", Email = "*****@*****.**", PhoneNumber = "+38 (073) 008-8500", EmailConfirmed = true, IsEnabled = true }; var result = await _accountManager.CreateUserAsync(applicationUser, new string[] { adminRoleName }, "mural1994"); if (!result.Item1) { throw new Exception($"Seeding user failed. Errors: {string.Join(Environment.NewLine, result.Item2)}"); } _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task SeedAsync() { await this.context.Database.MigrateAsync(); if (!await this.context.Roles.AnyAsync()) { await this.EnsureRoleAsync(UserRoles.Admin, UserRoles.Admin, ApplicationPermissions.GetAllPermissionValues()); await this.EnsureRoleAsync(UserRoles.User, UserRoles.User, new string[] { }); if (this.additionalRoles != null && this.additionalRoles.Count > 0) { foreach (var role in this.additionalRoles) { await this.EnsureRoleAsync(role.Key, role.Key, role.Value); } } } if (!await this.context.Users.AnyAsync()) { await this.CreateUserAsync("*****@*****.**", "Admin123!", "AdminFirst", "AdminLast", new string[] { UserRoles.Admin.ToString() }); await this.CreateUserAsync("*****@*****.**", "User123!", "UserFirst", "UserLast", new string[] { UserRoles.User.ToString() }); } if (!await this.context.AdminNavigationSchemes.AnyAsync()) { await this.InitDefaultAdminNavigationMenusAsync(); } }
public async Task SeedAsync() { await _identityContext.Database.MigrateAsync().ConfigureAwait(false); /* * Package Manager Console: * add-migration InitialIdentityMigration -Context IdentityDbContext * add-migration InitialApplicationMigration -Context ApplicationDbContext */ //Seems like this needs an update from Core //this is a workaround for fast standups as Migrate() should create this //_identityContext.Database.EnsureCreated(); if (!await _identityContext.Users.AnyAsync()) { _logger.LogInformation("Generating built in accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "tempP@ss123", "Built In Administrator", "*****@*****.**", "+1 (123) 000-0000", new[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Built In Standard User", "*****@*****.**", "+1 (123) 000-0001", new[] { userRoleName }); _logger.LogInformation("Identity User account generation completed"); } _logger.LogInformation("Seeding initial data completed"); }
/// <summary> /// Seed DB per tenant /// </summary> /// <param name="tenantName"></param> /// <returns></returns> public async Task SeedAsync(int tenantId, string adminPassword = "******")//string tenantName) { //await _context.Database.EnsureCreatedAsync(); //Apply migrations: tenant DB witll be created, then migrations applied await _context.Database.MigrateAsync().ConfigureAwait(false); using (var transaction = _context.Database.BeginTransaction()) { //1.Create 'predefined roles' in the Tenant DB //Create 'internal' roles with related permissions await EnsureRoleAsync(adminRoleName, "Tenant admin role", tenantId, ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(managerRoleName, "Manager role of the tenant", tenantId, ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(consultantRoleName, "Consultant role of the tenat", tenantId, ApplicationPermissions.GetConsultantPermissionValues()); await EnsureRoleAsync(supportRoleName, "Support contact role of the tenant", tenantId, new string[] { }); //TODO: 'Support contact' permissions await EnsureRoleAsync(communicationRoleName, "Communication role of the tenant", tenantId, new string[] { }); //TODO: 'Support role' permissions //await EnsureRoleAsync(userRoleName, "'Simple user' role of tenant", tenantId, new string[] { });//TODO: 'Simple user' permissions await EnsureRoleAsync(candidateRoleName, "Candidate - 'external role' of tenant. Candidate not exepted offer yet", tenantId, ApplicationPermissions.GetCandidatePermissionValues()); //TODO: candidate permissions await EnsureRoleAsync(TWRoleName, "TW - temporary worker 'internal role' of tenant", tenantId, new string[] { }); //TODO: TW permissions await EnsureRoleAsync(PLURoleName, "PLU - permanent worker 'interanl role' of tenant", tenantId, new string[] { }); //TODO: PLU permissions await EnsureRoleAsync(contractorRoleName, "Contractor - 'external role' of tenant", tenantId, new string[] { }); //TODO: contractor permissions await EnsureRoleAsync(clientRoleName, "Client - 'external role' of the tenant. Who are looking for workers", tenantId, ApplicationPermissions.GetClientPermissionValues()); //2. Create predefined users //NOTE: test users per role (to test logins under different accounts) await CreateTestUsers(tenantId, adminPassword); transaction.Commit(); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); //for (int i = 0; i < 5000; i++) //{ // await CreateTaskAsync(i); //} if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "Jelszo1", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "Jelszo1", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("dragan", "RInoxA2014!", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("boban", "RInoxA2014!", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.AppStories.AnyAsync()) { _logger.LogInformation("Seeding initial data"); Story story_1 = new Story { Lang = "en", Description = "Something Here _1", DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Story story_2 = new Story { Lang = "en", Description = "Something Here _2", DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Story story_3 = new Story { Lang = "en", Description = "Something Here _3", DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; _context.AppStories.Add(story_1); _context.AppStories.Add(story_2); _context.AppStories.Add(story_3); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.BibleBooks.AnyAsync()) { PopulateBibleMetadata(); } await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); }
virtual public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "SuperAdmin"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Super administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); if (!string.IsNullOrWhiteSpace(_defaultRoleName)) { await EnsureRoleAsync(_defaultRoleName, "Default public role", new string[] { }); } await CreateUserAsync("superadmin", "Abcd@123", "Super Administrator", "*****@*****.**", "7846745764", new string[] { adminRoleName }); await CreateUserAsync("user", "Abcd@123", "Inbuilt Standard User", "*****@*****.**", "9574574687", new string[] { userRoleName }); // await _context.SaveChangesAsync(); _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task EnsureAdminIdentitiesAsync() { await EnsureRoleAsync(DefaultRoleNames.Administrator, "Default administrator", _applicationPermissions.GetAllPermissionValues()); await CreateUserAsync(DefaultUserNames.Administrator, "admin123", "Admin", "Blazor", DefaultRoleNames.Administrator, "*****@*****.**", "+1 (123) 456-7890", new string[] { DefaultRoleNames.Administrator }); IdentityRole <Guid> adminRole = await _roleManager.FindByNameAsync(adminRoleName); var AllClaims = _applicationPermissions.GetAllPermissionValues().Distinct(); var RoleClaims = (await _roleManager.GetClaimsAsync(adminRole)).Select(c => c.Value).ToList(); var NewClaims = AllClaims.Except(RoleClaims); foreach (string claim in NewClaims) { await _roleManager.AddClaimAsync(adminRole, new Claim(ClaimConstants.Permission, claim)); } var DeprecatedClaims = RoleClaims.Except(AllClaims); var roles = await _roleManager.Roles.ToListAsync(); foreach (string claim in DeprecatedClaims) { foreach (var role in roles) { await _roleManager.RemoveClaimAsync(role, new Claim(ClaimConstants.Permission, claim)); } } _logger.LogInformation("Inbuilt account generation completed"); }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; //________feito por mim const string AU_ManagerRoleName = "au_manager"; const string AU_OperatorRoleName = "au_operator"; const string AU_Operator_CustomersRoleName = "au_operator_customers"; //________ await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); //________feito por mim await EnsureRoleAsync(AU_OperatorRoleName, "Default AU_Operator", new string[] { ApplicationPermissions.GetPermissionByName("View E_Invoices").Value, }); await EnsureRoleAsync(AU_Operator_CustomersRoleName, "Default AU_Operator_Customers", new string[] { ApplicationPermissions.GetPermissionByName("View E_Customers").Value, ApplicationPermissions.GetPermissionByName("Create E_Customers").Value, ApplicationPermissions.GetPermissionByName("Delete E_Customers").Value, }); await EnsureRoleAsync(AU_ManagerRoleName, "Default AU_Manager", new string[] { ApplicationPermissions.GetPermissionByName("Search E_Invoices").Value, ApplicationPermissions.GetPermissionByName("Create E_Invoices").Value, ApplicationPermissions.GetPermissionByName("Update E_Invoices").Value, ApplicationPermissions.GetPermissionByName("Delete E_Invoices").Value, }); //________ await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "lastname", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "lastname", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } // if (!await _context.Products.AnyAsync() && !await _context.Params.AnyAsync()) // { // _logger.LogInformation("Seeding initial data"); // Product prod_1 = new Product // { // Title = "BMW M6", // Description = "Yet another masterpiece from the world's best car manufacturer", // }; // var param1 = new Param{Id = 1001}; // var param2 = new Param{Id = 1002}; // var param3 = new Param{Id = 1003}; // //var prodVat1 = new ProductVariant{VariantParam = param1, VariantValue = "xyz", Product = prod_1}; // Product prod_2 = new Product // { // Title = "Nissan Patrol", // Description = "A true man's choice", // }; // _context.Products.Add(prod_1); // _context.Products.Add(prod_2); // await _context.SaveChangesAsync(); // _logger.LogInformation("Seeding initial data completed"); // } }
public async Task SeedAsync(bool migrate) { if (migrate) { await _context.Database.MigrateAsync().ConfigureAwait(false); await _persistedGrantDbContext.Database.MigrateAsync(); await _configurationDbContext.Database.MigrateAsync(); } if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; //const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Administrator", ApplicationPermissions.GetAllPermissionValues()); //await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("Admin", "Admin", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new[] { adminRoleName }); //await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new [] {userRoleName}); _logger.LogInformation("Inbuilt account generation completed"); } await _context.SaveChangesAsync(); if (!await _configurationDbContext.Clients.AnyAsync()) { await _configurationDbContext.Clients.AddRangeAsync(IdentityServerConfig.GetClients().Select(m => m.ToEntity())); } if (!await _configurationDbContext.IdentityResources.AnyAsync()) { await _configurationDbContext.IdentityResources.AddRangeAsync(IdentityServerConfig.GetIdentityResources().Select(m => m.ToEntity())); } if (!await _configurationDbContext.ApiResources.AnyAsync()) { await _configurationDbContext.ApiResources.AddRangeAsync(IdentityServerConfig.GetApiResources().Select(m => m.ToEntity())); } await _configurationDbContext.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); }
public async Task SeedAsync() { await this.context.Database.MigrateAsync(); if (!await this.context.Roles.AnyAsync()) { await EnsureRoleAsync(UserRoles.Admin, "Administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(UserRoles.User, "User", new string[] { }); } if (!await this.context.Users.AnyAsync()) { await CreateUserAsync("*****@*****.**", "Admin123!", "AdminFirst", "AdminLast", new string[] { UserRoles.Admin.ToString() }); await CreateUserAsync("*****@*****.**", "User123!", "UserFirst", "UserLast", new string[] { UserRoles.User.ToString() }); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); } }
public async Task SeedAsync() { await this.context.Database.MigrateAsync().ConfigureAwait(false); if (!await this.context.Roles.AnyAsync()) { await EnsureRoleAsync(Roles.Admin, "Admin", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(Roles.User, "User", new string[] { }); } if (!await this.context.Users.AnyAsync()) { await CreateUserAsync("*****@*****.**", "admin", "AdminFirstName", "AdminLastName", new string[] { Roles.Admin }); await CreateUserAsync("*****@*****.**", "admin", "User1FirstName", "User1LastName", new string[] { Roles.User }); await CreateUserAsync("*****@*****.**", "admin", "User2FirstName", "User2LastName", new string[] { Roles.User }); } }
private async Task SeedASPIdentityCoreAsync() { if (!await _context.Users.AnyAsync()) { //Generating inbuilt accounts const string adminRoleName = "Administrator"; const string userRoleName = "User"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "admin123", "Admin", "Blazor", "Administrator", "*****@*****.**", "+1 (123) 456-7890", new string[] { adminRoleName }); await CreateUserAsync("user", "user123", "User", "Blazor", "User Blazor", "*****@*****.**", "+1 (123) 456-7890`", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await CreateUserAsync("*****@*****.**", "Password1.", "Administrator", "*****@*****.**", "", new string[] { adminRoleName }); await CreateUserAsync("*****@*****.**", "Password1.", "Administrator", "*****@*****.**", "", new string[] { adminRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
private async Task SeedASPIdentityCoreAsync() { if (!await _context.Users.AnyAsync()) { //Generating inbuilt accounts const string adminRoleName = "Administrator"; const string userRoleName = "User"; const string coordinatorRoleName = "Coordinator"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await EnsureRoleAsync(coordinatorRoleName, "Default coordinator", new string[] { }); await CreateUserAsync("admin", "Admin123456", "Admin", "YLSPTeam", "Administrator YLSP", "*****@*****.**", "+1 (123) 456-7890", new string[] { adminRoleName }); await CreateUserAsync("user", "User123456", "User", "YLSPTeam", "User YLSP", "*****@*****.**", "+1 (123) 456-7890`", new string[] { userRoleName }); await CreateUserAsync("coordinator", "Coordinator123456", "Coordinator", "YLSPTeam", "Coordinator YLSP", "*****@*****.**", "+7 (999) 825-0380`", new string[] { coordinatorRoleName, userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } else { const string adminRoleName = "Administrator"; IdentityRole <Guid> adminRole = await _roleManager.FindByNameAsync(adminRoleName); var AllClaims = ApplicationPermissions.GetAllPermissionValues().Distinct(); var RoleClaims = (await _roleManager.GetClaimsAsync(adminRole)).Select(c => c.Value).ToList(); var NewClaims = AllClaims.Except(RoleClaims); foreach (string claim in NewClaims) { await _roleManager.AddClaimAsync(adminRole, new Claim(ClaimConstants.Permission, claim)); } var DeprecatedClaims = RoleClaims.Except(AllClaims); var roles = await _roleManager.Roles.ToListAsync(); foreach (string claim in DeprecatedClaims) { foreach (var role in roles) { await _roleManager.RemoveClaimAsync(role, new Claim(ClaimConstants.Permission, claim)); } } } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Employees.AnyAsync()) { _logger.LogInformation("Seeding initial data"); Employee emp1 = new Employee("Allan", 100, 150, null); Employee emp2 = new Employee("Martin", 220, 100, null); Employee emp3 = new Employee("Jamie", 150, null, null); Employee emp4 = new Employee("Alex", 275, 100, null); Employee emp5 = new Employee("Steve", 400, 150, null); Employee emp6 = new Employee("David", 190, 400, null); _context.Employees.Add(emp1); _context.Employees.Add(emp2); _context.Employees.Add(emp3); _context.Employees.Add(emp4); _context.Employees.Add(emp5); _context.Employees.Add(emp6); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+61433426868", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+61433426868", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "wsiz@sh", "Inbuilt Administrator", "*****@*****.**", "+48 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "wsiz@sh", "Inbuilt Standard User", "*****@*****.**", "+48 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Domyślny administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Domyślny użytkownik", new string[] { }); await CreateUserAsync("admin", "Adminadmin12#", "Wbudowane konto administratora", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "Useruser12#", "Wbudowane konto użytkownika", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
public virtual async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating default accounts"); const string adminRoleName = "administrator"; const string userRoleName = "ot"; await EnsureRoleAsync(adminRoleName, "Manage system", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Occupational Therapist", new string[] { }); await CreateUserAsync("admin", "q", "David Winslow", "*****@*****.**", "+27 (83) 823-0738", new[] { adminRoleName }); await CreateUserAsync("aislinn", "q", "Aislinn Winslow", "*****@*****.**", "+27 (72) 441-1941", new[] { userRoleName }); _logger.LogInformation("Setup of default accounts completed"); } }
virtual public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("*****@*****.**", "P@ssw0rd!", "Isak Vidinghoff", "*****@*****.**", "+46 73 728 33 75", new string[] { adminRoleName }); await CreateUserAsync("*****@*****.**", "P@ssw0rd!", "Pelle Johansson", "*****@*****.**", "+46 00 000 00 00", new string[] { adminRoleName }); await CreateUserAsync("*****@*****.**", "P@ssw0rd!", "Niklas Neuendorff", "*****@*****.**", "+46 00 000 00 00", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); // await _context.Database.EnsureCreatedAsync(); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "super administrator"; const string groupAdminRoleName = "group administrator"; const string userRoleName = "user"; const string respondentRoleName = "respondent"; await EnsureRoleAsync(adminRoleName, "Super administrator", 0, ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(groupAdminRoleName, "Group administrator", 1, ApplicationPermissions.GetAllGroupPermissionValues()); await EnsureRoleAsync(userRoleName, "Basic user", 2, ApplicationPermissions.GetAdministrativePermissionValues()); await EnsureRoleAsync(respondentRoleName, "Survey Respondent", 3, new string[] { }); var adminAccounts = _configuration.GetSection("AdminAccounts").GetChildren(); _logger.LogInformation("Creating admin accounts."); if (adminAccounts.Count() == 0) { _logger.LogWarning("No admin accounts exist."); // throw new Exception("No admin accounts in configuration."); } foreach (var section in adminAccounts) { var username = section.GetValue <string>("Username"); var password = section.GetValue <string>("Password"); await CreateUserAsync(username, password, "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); } //await CreateUserAsync("admin2", "tempP@ss456", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); //await CreateUserAsync("user", "tempP@ss789", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); //await CreateUserAsync("respondent", "@ss789", "Respondent User", "*****@*****.**", "+1 (123) 000-0001", new string[] { respondentRoleName }); //smto = await CreateUserAsync("smto", "tempP@ss789", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); //tts = await CreateUserAsync("tts", "tempP@ss789", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.UserGroups.AnyAsync()) { _logger.LogInformation("Seeding initial data"); UserGroup TTS = new UserGroup() { Name = "TTS", Members = new List <GroupMember>(), ApiKeySettings = new ApiKeys() { MailgunApiKey = "TTSMail", GoogleMapsApiKey = "TTSGoogle", MapBoxApiKey = "TTSMapbox" } }; UserGroup SMTO = new UserGroup() { Name = "StudentMove", Members = new List <GroupMember>(), ApiKeySettings = new ApiKeys() { MailgunApiKey = "SMTOMail", GoogleMapsApiKey = "SMTOGoogle", MapBoxApiKey = "SMTOMapbox" } }; _context.UserGroups.Add(TTS); _context.UserGroups.Add(SMTO); /*Survey TTSSurvey; * using (StreamReader r = new StreamReader("structure.json")) * { * var jsonFile = r.ReadToEnd(); * TTSSurvey = JsonConvert.DeserializeObject<Survey>(jsonFile, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects}); * } * * _context.Surveys.Add(TTSSurvey);*/ await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { const string adminRoleName = "administrator"; const string employerRoleName = "employer"; const string proRoleName = "professional"; await _userService.EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await _userService.EnsureRoleAsync(employerRoleName, "Default employer", new string[] { }); await _userService.EnsureRoleAsync(proRoleName, "Default professional", new string[] { }); // create admin await _userService.CreateAdminAsync( fullName : "Rabbit Heart", password : "******", email : "*****@*****.**" ); // create employer ApplicationUser employer = await _userService.CreateEmployerAsync( fullName : "Diana Prince", password : "******", email : "*****@*****.**", companyName : "Amazonian-Olympian" ); // create professional await _userService.CreateProfessionalAsync( fullName : "Clark Kent", password : "******", email : "*****@*****.**" ); _logger.LogInformation("Inbuilt account generation completed"); if (!await _context.Jobs.AnyAsync()) { // create jobs Job job1 = new Job { Name = "Entry Cook", Description = "Entry level cook for our restaurant.", PositionsToFill = 2, Employer = employer.Employer }; _jobRepository.SaveJob(job1); Job job2 = new Job { Name = "Front Desk Agent", Description = "Agent to serve guest checking into our hotel.", PositionsToFill = 4, Employer = employer.Employer }; _jobRepository.SaveJob(job2); _logger.LogInformation("Inbuilt job generation completed"); } } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating users account"); const string adminRoleName = RoleName.Admin; const string supportRoleName = RoleName.Support; await EnsureRoleAsync(adminRoleName, ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(supportRoleName, new string[] { }); await CreateUserAsync("admin", "Admin@123", "Administrator", "*****@*****.**", new[] { adminRoleName }); var supportUser = await CreateUserAsync("support", "Support@123", "Support User", "*****@*****.**", new[] { supportRoleName }); var supportUser2 = await CreateUserAsync("support2", "Support@123", "Support User 2", "*****@*****.**", new[] { supportRoleName }); _logger.LogInformation("User accounts generation completed"); if (await _context.Users.AnyAsync() && !await _context.TaskItems.AnyAsync()) { _logger.LogInformation("Seeding initial data"); var tasks = new List <TaskItem> { new TaskItem { Task = "Task item one", UserOwnerId = supportUser.Id, // DateCreated = DateTime.UtcNow }, new TaskItem { Task = "Task item two", UserOwnerId = supportUser.Id }, new TaskItem { Task = "Task item three", UserOwnerId = supportUser2.Id }, new TaskItem { Task = "Task item four", UserOwnerId = supportUser2.Id }, new TaskItem { Task = "Task item five", UserOwnerId = supportUser.Id }, }; _context.TaskItems.AddRange(tasks); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); await CreateUserAsync("admin", "Admin@123", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); //await CreateUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); //await CreateUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.DefaultDices.AnyAsync()) { List <DefaultDice> defaultDices = new List <DefaultDice>(); defaultDices.Add(new DefaultDice() { Name = "D4", Icon = "icon-d4-thin" }); defaultDices.Add(new DefaultDice() { Name = "D6", Icon = "icon-d6-thin" }); defaultDices.Add(new DefaultDice() { Name = "D8", Icon = "icon-d8-thin" }); defaultDices.Add(new DefaultDice() { Name = "D10", Icon = "icon-d10-thin" }); defaultDices.Add(new DefaultDice() { Name = "D12", Icon = "icon-d12-thin" }); defaultDices.Add(new DefaultDice() { Name = "D20", Icon = "icon-d20-thin" }); defaultDices.Add(new DefaultDice() { Name = "D100", Icon = "icon-d100-thin" }); _context.DefaultDices.AddRange(defaultDices); await _context.SaveChangesAsync(); } if (!await _context.ConditionOperators.AnyAsync()) { List <ConditionOperator> conditionOperators = new List <ConditionOperator>(); conditionOperators.Add(new ConditionOperator() { IsNumeric = false, Symbol = "==", Name = "Equals" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = false, Symbol = "!=", Name = "Not equals" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = false, Symbol = "", Name = "Is blank" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = false, Symbol = "", Name = "Is not blank" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = false, Symbol = "", Name = "Contains" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = false, Symbol = "", Name = "Does not contain" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = true, Symbol = ">", Name = "Greater than" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = true, Symbol = ">=", Name = "Equal to or greater than" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = true, Symbol = "<", Name = "Less than" }); conditionOperators.Add(new ConditionOperator() { IsNumeric = true, Symbol = "<=", Name = "Equal to or less than" }); _context.ConditionOperators.AddRange(conditionOperators); await _context.SaveChangesAsync(); } if (!await _context.Roles.Where(x => x.Name == "gm").AnyAsync()) { const string gmRoleName = "gm"; await EnsureRoleAsync(gmRoleName, "gm", new string[] { }); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await ensureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await ensureRoleAsync(userRoleName, "Default user", new string[] { }); await createUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+84 (907) 477-489", new string[] { adminRoleName }); await createUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+84 (944) 776-636", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.Customers.AnyAsync() && !await _context.ProductCategories.AnyAsync()) { _logger.LogInformation("Seeding initial data"); Customer cust_1 = new Customer { Name = "Ebrain Team", Email = "*****@*****.**", Gender = Core.Gender.Male, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Customer cust_2 = new Customer { Name = "Itachi Uchiha", Email = "*****@*****.**", PhoneNumber = "+81123456789", Address = "Some fictional Address, Street 123, Konoha", City = "Konoha", Gender = Core.Gender.Male, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Customer cust_3 = new Customer { Name = "John Doe", Email = "*****@*****.**", PhoneNumber = "+18585858", Address = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet", City = "Lorem Ipsum", Gender = Core.Gender.Male, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Customer cust_4 = new Customer { Name = "Jane Doe", Email = "*****@*****.**", PhoneNumber = "+18585858", Address = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet", City = "Lorem Ipsum", Gender = Core.Gender.Male, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; ProductCategory prodCat_1 = new ProductCategory { Name = "None", Description = "Default category. Products that have not been assigned a category", DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Product prod_1 = new Product { Name = "BMW M6", Description = "Yet another masterpiece from the world's best car manufacturer", BuyingPrice = 109775, SellingPrice = 114234, UnitsInStock = 12, IsActive = true, ProductCategory = prodCat_1, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Product prod_2 = new Product { Name = "Nissan Patrol", Description = "A true man's choice", BuyingPrice = 78990, SellingPrice = 86990, UnitsInStock = 4, IsActive = true, ProductCategory = prodCat_1, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow }; Order ordr_1 = new Order { Discount = 500, Cashier = await _context.Users.FirstAsync(), Customer = cust_1, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow, OrderDetails = new List <OrderDetail>() { new OrderDetail() { UnitPrice = prod_1.SellingPrice, Quantity = 1, Product = prod_1 }, new OrderDetail() { UnitPrice = prod_2.SellingPrice, Quantity = 1, Product = prod_2 }, } }; Order ordr_2 = new Order { Cashier = await _context.Users.FirstAsync(), Customer = cust_2, DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow, OrderDetails = new List <OrderDetail>() { new OrderDetail() { UnitPrice = prod_2.SellingPrice, Quantity = 1, Product = prod_2 }, } }; _context.Customers.Add(cust_1); _context.Customers.Add(cust_2); _context.Customers.Add(cust_3); _context.Customers.Add(cust_4); _context.Products.Add(prod_1); _context.Products.Add(prod_2); _context.Orders.Add(ordr_1); _context.Orders.Add(ordr_2); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } }
public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Products.AnyAsync()) { for (int i = 0; i < 10000; i++) { var testProduct = new Product { Name = "Test product" + i, Code = "ABCD-2315", Description = "Test Data", Price = 599.9, Rating = 3.2, ImageUrl = "", UnitsInStock = 12, IsActive = true, IsDiscontinued = false }; _context.Products.Add(testProduct); } await _context.SaveChangesAsync(); } if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await ensureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await ensureRoleAsync(userRoleName, "Default user", new string[] { }); await createUserAsync("admin", "tempP@ss123", "Inbuilt Administrator", "*****@*****.**", "+36 (20) 000-0000", new string[] { adminRoleName }); await createUserAsync("user", "tempP@ss123", "Inbuilt Standard User", "*****@*****.**", "+336 (20) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.Customers.AnyAsync()) { _logger.LogInformation("Seeding initial data"); var testCustomer1 = new Customer { FirstName = "David Nemeth", LastName = "", DateOfBirth = new DateTime(1990, 02, 26), Email = "*****@*****.**", Gender = Gender.Male, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, CreatedBy = "Seeded Test Data", UpdatedBy = "No Update since Creation" }; var testCustomer2 = new Customer { FirstName = "Temp2 Name2", LastName = "", DateOfBirth = new DateTime(1995, 12, 30), Email = "*****@*****.**", Gender = Gender.Male, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, CreatedBy = "Seeded Test Data", UpdatedBy = "No Update since Creation" }; var testCustomer3 = new Customer { FirstName = "Temp3 Name3", LastName = "", DateOfBirth = new DateTime(2001, 04, 15), Email = "*****@*****.**", Gender = Gender.Male, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, CreatedBy = "Seeded Test Data", UpdatedBy = "No Update since Creation" }; var testCustomer4 = new Customer { FirstName = "Temp4 Name4", LastName = "", DateOfBirth = new DateTime(1960, 06, 12), Email = "*****@*****.**", Gender = Gender.Male, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, CreatedBy = "Seeded Test Data", UpdatedBy = "No Update since Creation" }; var testOrder1 = new Order { AppUser = await _context.Users.FirstAsync(), Customer = testCustomer1, Price = 2500, Description = "ugly tshirt from china", CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; var testOrder2 = new Order { AppUser = await _context.Users.FirstAsync(), Customer = testCustomer1, Price = 2500, Description = "Big ass TeLieVision", CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; var testProduct = new Product { Name = "Test product", Code = "ABCD-2315", Description = "Test Data", Price = 599.9, Rating = 3.2, ImageUrl = "", UnitsInStock = 12, IsActive = true, IsDiscontinued = false }; for (int i = 0; i < 1000; i++) { _context.Products.Add(testProduct); } _context.Customers.Add(testCustomer1); _context.Customers.Add(testCustomer2); _context.Customers.Add(testCustomer3); _context.Customers.Add(testCustomer4); _context.Orders.Add(testOrder1); _context.Orders.Add(testOrder2); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } }
virtual public async Task SeedAsync() { await _context.Database.MigrateAsync().ConfigureAwait(false); if (!await _context.Users.AnyAsync()) { _logger.LogInformation("Generating inbuilt accounts"); const string adminRoleName = "administrator"; const string userRoleName = "user"; await EnsureRoleAsync(adminRoleName, "Default administrator", ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(userRoleName, "Default user", new string[] { }); if (!string.IsNullOrWhiteSpace(_defaultRoleName)) { await EnsureRoleAsync(_defaultRoleName, "Default public role", new string[] { }); } await CreateUserAsync("admin", "start@31Trwz", "Inbuilt", "Administrator", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName }); await CreateUserAsync("user", "start@31Trwz", "Inbuilt", "Standard User", "*****@*****.**", "+1 (123) 000-0001", new string[] { userRoleName }); _logger.LogInformation("Inbuilt account generation completed"); } if (!await _context.Languages.AnyAsync()) { Language lng_1 = new Language { LocalName = "Arabic - الـعـربـيـة", LanguageCode = "ar", CountryCode = "DZ", SettingsLanguage = SettingsLanguage.Arabic }; Language lng_2 = new Language { LocalName = "English - US English (Default)", LanguageCode = "en", CountryCode = "US", SettingsLanguage = SettingsLanguage.English }; Language lng_3 = new Language { LocalName = "Chinese - 中文", LanguageCode = "zh", CountryCode = "CN", SettingsLanguage = SettingsLanguage.Chinese }; Language lng_4 = new Language { LocalName = "Indian - हिन्दी", LanguageCode = "hi", CountryCode = "IN", SettingsLanguage = SettingsLanguage.Hindi }; Language lng_5 = new Language { LocalName = "Spanish - Español", LanguageCode = "es", CountryCode = "ES", SettingsLanguage = SettingsLanguage.Spanish }; Language lng_6 = new Language { LocalName = "Frensh - Français", LanguageCode = "fr", CountryCode = "FR", SettingsLanguage = SettingsLanguage.French }; Language lng_7 = new Language { LocalName = "Bengali - বাংলা", LanguageCode = "bn", CountryCode = "BD", SettingsLanguage = SettingsLanguage.Bengali }; Language lng_8 = new Language { LocalName = "Russian - Русский", LanguageCode = "ru", CountryCode = "RU", SettingsLanguage = SettingsLanguage.Russian }; Language lng_9 = new Language { LocalName = "Portuguese - Português", LanguageCode = "pt", CountryCode = "PT", SettingsLanguage = SettingsLanguage.Portuguese }; Language lng_10 = new Language { LocalName = "Indonisan - Bahasa Indonesia", LanguageCode = "id", CountryCode = "ID", SettingsLanguage = SettingsLanguage.Indonesian }; Language lng_11 = new Language { LocalName = "German - Deutsch", LanguageCode = "de", CountryCode = "DE", SettingsLanguage = SettingsLanguage.German }; Language lng_12 = new Language { LocalName = "Japanese - 日本語", LanguageCode = "ja", CountryCode = "JP", SettingsLanguage = SettingsLanguage.Japanese }; Language lng_13 = new Language { LocalName = "Corian - 한국어", LanguageCode = "ko", CountryCode = "KR", SettingsLanguage = SettingsLanguage.Corian }; Language lng_14 = new Language { LocalName = "Turkish - Türkçe", LanguageCode = "tr", CountryCode = "TR", SettingsLanguage = SettingsLanguage.Turkish }; Language lng_15 = new Language { LocalName = "Italian - Italiano", LanguageCode = "it", CountryCode = "IT", SettingsLanguage = SettingsLanguage.Italian }; _context.Languages.Add(lng_1); _context.Languages.Add(lng_2); _context.Languages.Add(lng_3); _context.Languages.Add(lng_4); _context.Languages.Add(lng_5); _context.Languages.Add(lng_6); _context.Languages.Add(lng_7); _context.Languages.Add(lng_8); _context.Languages.Add(lng_9); _context.Languages.Add(lng_10); _context.Languages.Add(lng_11); _context.Languages.Add(lng_12); _context.Languages.Add(lng_13); _context.Languages.Add(lng_14); _context.Languages.Add(lng_15); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } ; if (!await _context.Articles.AnyAsync() && !await _context.Categories.AnyAsync()) { _logger.LogInformation("Seeding initial data"); Category prodCat_1 = new Category { Name = "All", Description = "Default category. Products that have not been assigned a category" }; Category prodCat_2 = new Category { Name = "Tablet", Description = "Tablet" }; Category prodCat_3 = new Category { Name = "Laptop", Description = "Laptop" }; Category prodCat_4 = new Category { Name = "Headphones", Description = "Headphones" }; Category prodCat_5 = new Category { Name = "Smartphones", Description = "Smartphones" }; Article prod_1 = new Article { Title = "iPhone 7", Description = "iPhone 7", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_5, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_2 = new Article { Title = "iPad Pro", Description = "iPad Pro", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_2, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_3 = new Article { Title = "Sony TV RT56", Description = "Sony TV RT56", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_4 = new Article { Title = "Philips V56", Description = "Philips V56", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_5 = new Article { Title = "Dell V756", Description = "Dell V756", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_3, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_6 = new Article { Title = "Canon D-67i", Description = "Canon D-67i", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_7 = new Article { Title = "Samsung V54", Description = "Samsung V54", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_8 = new Article { Title = "Dell 786i", Description = "Dell 786i", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_3, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_9 = new Article { Title = "iMac 27inch", Description = "iMac 27inch", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_10 = new Article { Title = "Headphones", Description = "Headphones", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_4, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_11 = new Article { Title = "Dell V-964i", Description = "Dell V-964i", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_3, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_12 = new Article { Title = "Dell 786i", Description = "Dell 786i", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_3, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_13 = new Article { Title = "Asus GT67i", Description = "Asus GT67i", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_3, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_14 = new Article { Title = "Canon 675-D", Description = "Canon 675-D", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_15 = new Article { Title = "iMac", Description = "iMac", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_16 = new Article { Title = "Sony TV-675i", Description = "Sony TV-675i", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_17 = new Article { Title = "Samsung Y78", Description = "Samsung Y78", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; Article prod_18 = new Article { Title = "Nikon", Description = "Nikon", BuyingPrice = 550, SellingPrice = 650, UnitsInStock = 10, IsActive = true, Category = prodCat_1, Created = DateTime.UtcNow, Updated = DateTime.UtcNow }; _context.Articles.Add(prod_1); _context.Articles.Add(prod_2); _context.Articles.Add(prod_3); _context.Articles.Add(prod_4); _context.Articles.Add(prod_5); _context.Articles.Add(prod_6); _context.Articles.Add(prod_7); _context.Articles.Add(prod_8); _context.Articles.Add(prod_9); _context.Articles.Add(prod_10); _context.Articles.Add(prod_11); _context.Articles.Add(prod_12); _context.Articles.Add(prod_13); _context.Articles.Add(prod_14); _context.Articles.Add(prod_15); _context.Articles.Add(prod_16); _context.Articles.Add(prod_17); _context.Articles.Add(prod_18); await _context.SaveChangesAsync(); _logger.LogInformation("Seeding initial data completed"); } }