public void UpdateCategory(Category category) { using (var context = new MvcComContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void UpdateProduct(Product product) { using (var context = new MvcComContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveCategory(Category category) { using (var context = new MvcComContext()) { context.Categories.Add(category); context.SaveChanges(); } }
public void SaveProduct(Product product) { using (var context = new MvcComContext()) { context.Products.Add(product); context.SaveChanges(); } }
public void DeleteCategory(int ID) { using (var context = new MvcComContext()) { var category = context.Categories.Find(ID); //context.Entry(category).State = System.Data.Entity.EntityState.Deleted; //both will work context.Categories.Remove(category); context.SaveChanges(); } }