public void Add(Product product) { using (ETradeContext context = new ETradeContext()) { context.Products.Add(product); context.SaveChanges(); } }
public void Delete(Product product) { using (ETradeContext context = new ETradeContext()) { var entity = context.Entry(product); entity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Update(Product product) { using (ETradeContext context = new ETradeContext()) { //context.Products.Add(product); var entity = context.Entry(product); entity.State = EntityState.Modified; context.SaveChanges(); } }