private async Task PopulateCustomersAndUsers(string defaultUserEmail, string defaultUserPassword) { var customerRoles = _data.CustomerRoles(_config.SeedSampleData); await SaveRange(customerRoles.Where(x => x != null)); //admin user var adminUser = new Customer { CustomerGuid = Guid.NewGuid(), Email = defaultUserEmail, Username = defaultUserEmail, Password = defaultUserPassword, PasswordFormat = PasswordFormat.Clear, PasswordSalt = "", Active = true, CreatedOnUtc = DateTime.UtcNow, LastActivityDateUtc = DateTime.UtcNow, }; var adminAddress = _data.AdminAddress(); adminUser.Addresses.Add(adminAddress); adminUser.BillingAddress = adminAddress; adminUser.ShippingAddress = adminAddress; var adminRole = customerRoles.First(x => x.SystemName == SystemCustomerRoleNames.Administrators); var forumRole = customerRoles.First(x => x.SystemName == SystemCustomerRoleNames.ForumModerators); var registeredRole = customerRoles.First(x => x.SystemName == SystemCustomerRoleNames.Registered); adminUser.CustomerRoleMappings.Add(new CustomerRoleMapping { CustomerId = adminUser.Id, CustomerRoleId = adminRole.Id }); adminUser.CustomerRoleMappings.Add(new CustomerRoleMapping { CustomerId = adminUser.Id, CustomerRoleId = forumRole.Id }); adminUser.CustomerRoleMappings.Add(new CustomerRoleMapping { CustomerId = adminUser.Id, CustomerRoleId = registeredRole.Id }); await Save(adminUser); // Set default customer name var firstAddress = adminUser.Addresses.FirstOrDefault(); _db.GenericAttributes.AddRange(new[] { new GenericAttribute { EntityId = adminUser.Id, Key = "FirstName", KeyGroup = "Customer", Value = firstAddress.FirstName }, new GenericAttribute { EntityId = adminUser.Id, Key = "LastName", KeyGroup = "Customer", Value = firstAddress.LastName } }); await _db.SaveChangesAsync(); // Built-in user for search engines (crawlers) var guestRole = customerRoles.FirstOrDefault(x => x.SystemName == SystemCustomerRoleNames.Guests); var customer = _data.SearchEngineUser(); customer.CustomerRoleMappings.Add(new CustomerRoleMapping { CustomerId = customer.Id, CustomerRoleId = guestRole.Id }); await Save(customer); // Built-in user for background tasks customer = _data.BackgroundTaskUser(); customer.CustomerRoleMappings.Add(new CustomerRoleMapping { CustomerId = customer.Id, CustomerRoleId = guestRole.Id }); await Save(customer); // Built-in user for the PDF converter customer = _data.PdfConverterUser(); customer.CustomerRoleMappings.Add(new CustomerRoleMapping { CustomerId = customer.Id, CustomerRoleId = guestRole.Id }); await Save(customer); }