public static void AddCategory(string name, string backgroundImagePath, string link, string title) { PizzaVikiCategoriesEntities pizzaVikiDB = new PizzaVikiCategoriesEntities(); pizzaVikiDB.Categories.AddObject(new Category() { Name = name, BackgroundImagePath = backgroundImagePath, Link = link, Title = title }); pizzaVikiDB.SaveChanges(); }
public static void AddProduct( string categoryName, string productName, string backgroundImagePath, string ingredients, string lowestPrice, string averagePrice, string highestPrice, float? weight) { PizzaVikiCategoriesEntities pizzaVikiDB = new PizzaVikiCategoriesEntities(); int categoryID = pizzaVikiDB.Categories.Single(x => x.Name.Equals(categoryName)).id; pizzaVikiDB.Products.AddObject(new Product() { CategoryID = categoryID, Name = productName, BackgroundImagePath = backgroundImagePath, Ingredients = ingredients, LowestPrice = lowestPrice, AveragePrice = averagePrice, HighestPrice = highestPrice, Weight = weight, }); pizzaVikiDB.SaveChanges(); }