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(); //} }
public ProductsDbRepository(MyCostsDbContext db) { this.db = db; }
public CategoriesDbRepository(MyCostsDbContext db) { this.db = db; }