Пример #1
0
 public static void Initialize(MyCostsDbContext context)
 {
     //var food = new ProductCategory() { Name = "Еда" };
     //var clothes = new ProductCategory() { Name = "Одежда, обувь и аксессуары" };
     //if (!context.ProductCategories.Any())
     //{
     //    context.ProductCategories.AddRange(food, clothes);
     //    context.SaveChanges();
     //}
     //var apple = new Product() { Name = "Яблоко", Category = food };
     //var cheese = new Product() { Name = "Сыр", Category = food };
     //var pants = new Product() { Name = "Штаны", Category = clothes };
     //var shoes = new Product() { Name = "Туфли", Category = clothes };
     //if (!context.Products.Any())
     //{
     //    context.Products.AddRange(apple, cheese, pants, shoes);
     //    context.SaveChanges();
     //}
 }
Пример #2
0
 public ProductsDbRepository(MyCostsDbContext db)
 {
     this.db = db;
 }
Пример #3
0
 public CategoriesDbRepository(MyCostsDbContext db)
 {
     this.db = db;
 }