public bool Delete(productDetail Product) { using (ProductEntities pre = new ProductEntities()) { try { int id = Convert.ToInt32(Product.Id); productDetail pd = pre.productDetails.Single(p => p.Id == id); pre.productDetails.Remove(pd); pre.SaveChanges(); return(true); } catch { return(false); } }; }
public bool Edit(productDetail Product) { using (ProductEntities pre = new ProductEntities()) { try { int id = Convert.ToInt32(Product.Id); productDetail pd = pre.productDetails.Single(p => p.Id == id); pd.productName = Product.productName; pd.productPrice = Product.productPrice; pd.productQuantity = Product.productQuantity; pd.productExpDate = Product.productExpDate; pd.Category = Product.Category; pre.SaveChanges(); return(true); } catch { return(false); } }; }
public bool Create(productDetail Product) { using (ProductEntities pre = new ProductEntities()) { try { productDetail pd = new productDetail(); pd.productName = Product.productName; pd.productPrice = Product.productPrice; pd.productQuantity = Product.productQuantity; pd.productExpDate = Product.productExpDate; pd.Category = Product.Category; pre.productDetails.Add(pd); pre.SaveChanges(); return(true); } catch { return(false); } }; }