public void Update(Product product) { using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext()) { onlineShoppingContext.Entry(product).State = System.Data.Entity.EntityState.Modified; onlineShoppingContext.SaveChanges(); } }
public void AddUser(Account account) { using (OnlineShoppingContext context = new OnlineShoppingContext()) { context.Accounts.Add(account); context.SaveChanges(); } }
public void AddProduct(Product product) { using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext()) { onlineShoppingContext.products.Add(product); onlineShoppingContext.SaveChanges(); } }
public void Update(Category category) { using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext()) { onlineShoppingContext.Entry(category).State = System.Data.Entity.EntityState.Modified; onlineShoppingContext.SaveChanges(); } }
public void AddCategory(Category category) { using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext()) { onlineShoppingContext.Categories.Add(category); onlineShoppingContext.SaveChanges(); } }
public void Delete(int id) { using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext()) { Product product = onlineShoppingContext.products.Find(id); onlineShoppingContext.products.Remove(product); onlineShoppingContext.SaveChanges(); } }
public void Delete(int id) { using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext()) { Category category = onlineShoppingContext.Categories.Find(id); onlineShoppingContext.Categories.Remove(category); onlineShoppingContext.SaveChanges(); } }