private void SeedPictures(StoreDB context) { for (int i = 0; i < 20; i++) { context.Set <Picture>().AddOrUpdate(new Picture { Name = "pict1.jpg", ProductId = 1 + 3 * i }); context.Set <Picture>().AddOrUpdate(new Picture { Name = "pict2.jpg", ProductId = 2 + 3 * i }); context.Set <Picture>().AddOrUpdate(new Picture { Name = "pict3.jpg", ProductId = 3 + 3 * i }); } context.SaveChanges(); }
public void InsertTransaction(PurchaseTransaction purchase) { using (var db = new StoreDB()) { PURCHASE_TRANSACTIONS prod = Mapper.Map <PURCHASE_TRANSACTIONS>(purchase); db.Set <PURCHASE_TRANSACTIONS>().Add(prod); db.SaveChanges(); } }
private void SeedCategories(StoreDB context) { for (int i = 1; i <= 5; i++) { var category = new Category() { Name = "Kategoria " + i.ToString() }; context.Set <Category>().AddOrUpdate(category); } context.SaveChanges(); }
private void SeedProducers(StoreDB context) { for (int i = 1; i <= 3; i++) { var producer = new Producer() { ProducerId = i, Name = "Producent " + i.ToString(), FirstName = "Tom", LastName = "Drugi" }; context.Set <Producer>().AddOrUpdate(producer); } context.SaveChanges(); }
private void SeedProducts(StoreDB context) { int sizes = Repository.Services.ProductService.AvailableSizes.Length; int colors = Repository.Services.ProductService.AvailableColors.Length; for (int i = 1; i <= 60; i++) { var product = new Product() { Category = context.Categories.Find(i % 5 + 1), ProducerId = (i - 1) / 20 + 1, Colors = i % ((1 << colors) - 1) + 1, Sizes = i % ((1 << sizes) - 1) + 1, Name = "Produkt " + i.ToString(), Price = i / 10M, Amount = (i < 5 ? 0 : i) }; context.Set <Product>().AddOrUpdate(product); } context.SaveChanges(); }
public GenericRepository(StoreDB context) { this.context = context; this.dbSet = context.Set <TEntity>(); }