Esempio n. 1
0
 public List <productDetail> FindAll()
 {
     using (ProductEntities pre = new ProductEntities()) {
         return(pre.productDetails.Select(pe => new productDetail
         {
             Id = pe.Id,
             productName = pe.productName,
             productPrice = pe.productPrice,
             productQuantity = pe.productQuantity,
             productExpDate = pe.productExpDate,
             Category = pe.Category
         }).ToList());
     };
 }
Esempio n. 2
0
 public productDetail Find(int id)
 {
     using (ProductEntities pre = new ProductEntities())
     {
         return(pre.productDetails.Where(pe => pe.Id == id).Select(pe => new productDetail
         {
             Id = pe.Id,
             productName = pe.productName,
             productPrice = pe.productPrice,
             productQuantity = pe.productQuantity,
             productExpDate = pe.productExpDate,
             Category = pe.Category
         }).First());
     };
 }
Esempio n. 3
0
 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);
         }
     };
 }
Esempio n. 4
0
 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);
         }
     };
 }
Esempio n. 5
0
 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);
         }
     };
 }