public int Update(int ProductId, ProductModel model) { using (var context = new ProductDataContext()) { context.Entry(model).State = EntityState.Modified; var rowsAffected = context.SaveChanges(); return(rowsAffected); } }
public int Add(ProductModel model) { using (var context = new ProductDataContext()) { context.Products.Add(model); var rowsAffected = context.SaveChanges(); return(rowsAffected); } }
public int Delete(int productID) { using (var context = new ProductDataContext()) { var product = context.Products.Find(productID); context.Products.Remove(product); var rowsAffected = context.SaveChanges(); return(rowsAffected); } }