internal void Populate() { var howManyFavoriteProducts = _randomizer.Number(10); var howManyReviews = _randomizer.Number(0, 5); var reviews = new List <ProductReview>(); for (var i = 0; i < howManyReviews; i++) { reviews.Add(new ProductReview { ProductId = _randomizer.Number(1, 5000), ReviewDate = this.DsDate.Past(4, DateTime.Now), ReviewText = DsRant.Review(_randomizer.Word()) }); } for (var i = 0; i < howManyFavoriteProducts; i++) { PreferredProducts.Add(_randomizer.Number(1, 5000)); } CartId = Guid.NewGuid(); ProductReviews = reviews; }
public static void Seed(IApplicationBuilder applicationBuilder) { using (var serviceScope = applicationBuilder.ApplicationServices.CreateScope()) { var context = serviceScope.ServiceProvider.GetService <WarehouseDbContext>(); if (context.Product.Any()) { return; } var commerce = new Commerce(); var finance = new Finance(); var lorem = new Lorem(); var company = new Company(); var internet = new Internet(); var name = new Name(); var rant = new Rant(); for (var i = 0; i < 100000; i++) { context.Product.Add(new Product { Category = commerce.Categories(1)[0], Color = commerce.Color(), Ean13 = commerce.Ean13(), Name = commerce.ProductName(), Price = decimal.Parse(commerce.Price()), Currency = finance.Currency().Code, Description = lorem.Sentences(), Company = company.CompanyName(), Mail = internet.Email(), Seller = name.FullName(), Review = rant.Review() }); } context.SaveChanges(); } }
public static string Review(string product) => Rant.Review(product);