Ejemplo n.º 1
0
 public static bool DeleteProduct(string productParam)
 {
     using (test_productEntities db = new test_productEntities())
     {
         ProductsTable ProductChose = db.ProductsTables.FirstOrDefault(a => a.ProductName == productParam);
         if (ProductChose == null)
         {
             return(false);
         }
         db.ProductsTables.Remove(ProductChose);
         db.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 2
0
 public static Product GetSpeseficProduct(string productParam)
 {
     using (test_productEntities db = new test_productEntities())
     {
         ProductsTable ProductChose = db.ProductsTables.FirstOrDefault(a => a.ProductName == productParam);
         if (ProductChose == null)
         {
             return(null);
         }
         return(new Product {
             ProductName = ProductChose.ProductName, Price = ProductChose.ProductPrice
         });
     }
 }
Ejemplo n.º 3
0
 public static bool EditProduct(string productname, Product Productparam)
 {
     try
     {
         using (test_productEntities db = new test_productEntities())
         {
             ProductsTable SelectedProuduct = db.ProductsTables.FirstOrDefault(a => a.ProductName == Productparam.ProductName);
             if (SelectedProuduct == null)
             {
                 return(false);
             }
             SelectedProuduct.ProductPrice = Productparam.Price;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
 public static bool AddProduct(Product Productparam)
 {
     try
     {
         using (test_productEntities db = new test_productEntities())
         {
             ProductsTable NewProduct = new ProductsTable
             {
                 ProductName  = Productparam.ProductName,
                 ProductPrice = Productparam.Price,
             };
             db.ProductsTables.Add(NewProduct);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }