Esempio n. 1
0
 // GET: Product
 public ActionResult Index()
 {
     try
     {
         var obtainprodcuts = Data.GetAllProducts();
         return(View(obtainprodcuts));
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         return(View());
     }
 }
Esempio n. 2
0
        public ActionResult Index()
        {
            try
            {
                var    obtainproducts = ProductData.GetAllProducts().Where(elem => elem.Stock > 0).ToList();
                string btnclick       = Request["searchitem"];
                string txtinput       = Request["itemtxt"];
                if (btnclick == "Search")
                {
                    var ProductResult = SearchItem(txtinput);

                    if (ProductResult.Count == 0)
                    {
                        Debug.WriteLine("Empty list");
                        return(View(ProductResult));
                    }
                    else
                    {
                        return(View(ProductResult));
                    }
                }
                return(View(obtainproducts));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(View());
            }
        }