public List <Stock> SetupStocks() { int counter = new int(); List <Stock> stocks = MockDataInitializer.GenerateStocks(); foreach (Stock s in stocks) { s.ID = ++counter; } return(stocks); }
protected override void Seed(CompanyStore.Data.CompanyStoreContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // // Create Department context.Departments.AddOrUpdate(e => e.Name, MockDataInitializer.GenerateDepartments().ToArray()); // Create Employees context.Employees.AddOrUpdate(e => e.FirstName, MockDataInitializer.GenerateEmployees().ToArray()); // Create Genres context.Categories.AddOrUpdate(g => g.Name, MockDataInitializer.GenerateCategories().ToArray()); // Create Devices context.Devices.AddOrUpdate(d => d.Name, MockDataInitializer.GenerateDevices().ToArray()); // Create Stocks context.Stocks.AddOrUpdate(MockDataInitializer.GenerateStocks().ToArray()); // Create Roles context.Roles.AddOrUpdate(r => r.Name, MockDataInitializer.GenerateRoles().ToArray()); // Create Users context.Users.AddOrUpdate(u => u.Username, new User[] { new User() { Email = "*****@*****.**", FirstName = "Wanasak", LastName = "Suraintaranggoon", Username = "******", IsLocked = false, CreatedDate = DateTime.Now, HashedPassword = "******", Salt = "ljd/YZrfxnkEoB0l2rvjgA==", Image = "twitter-profile.jpg" } }); // Create user admin for smudger context.UserRoles.AddOrUpdate(new UserRole[] { new UserRole() { UserID = 1, RoleID = 1 } }); }
public List <Stock> SetupStocks() { int counter = new int(); List <Stock> stocks = MockDataInitializer.GenerateStocks(); foreach (Stock s in stocks) { s.ID = ++counter; } Stock firstStock = stocks.First(); firstStock.Rentals.Add(MockDataInitializer.GenerateRentals().First()); firstStock.Rentals.First().ID = 1; firstStock.Rentals.First().Stock = firstStock; firstStock.IsAvailable = false; return(stocks); }