public ActionResult ListProducts()
        {
            if(User.Identity.IsAuthenticated)
            {
                ProductManager manager = new ProductManager();

                ProductListView _lstProducts = manager.GetProductList();
                return PartialView(_lstProducts);
            }
            return View();
        }
        public ActionResult AddProduct(ProductView pv)
        {
            if (ModelState.IsValid)
            {
                //ProductView pv = new ProductView() { ProudctName = _pname, ProductPrice = Convert.ToDecimal(_price), ProductDescription = _pdescription, CreatedBy = User.Identity.Name, CreatedDate = DateTime.Now, ModifiedBy = User.Identity.Name, ModifiedDate = DateTime.Now };
                pv.CreatedBy = User.Identity.Name;
                pv.CreatedDate = DateTime.Now;
                pv.UpdateBy = User.Identity.Name;
                pv.UpdatedDate = DateTime.Now;

                ProductManager _manager = new ProductManager();

                _manager.AddProduct(pv);
                return RedirectToAction("ListProducts");                
            }
            return View();

        }
        public ActionResult UpdateProduct(ProductView pv)
        {
            if (ModelState.IsValid)
            {

                //ProductView pv = new ProductView() { Id = int.Parse(_id), ProductName = _pname, ProductProce = Convert.ToDecimal(_price), ProductDescription = _pdescription, UpdateBy = User.Identity.Name, UpdatedDate = DateTime.Now };
                pv.UpdateBy = User.Identity.ToString();
                pv.UpdatedDate = DateTime.Now;
                ProductManager _manager = new ProductManager();


                _manager.UpdateProduct(pv);
                return RedirectToAction("ListProducts");
                //return Json(new { success = true });
            }
            return View();

        }
        //[Authorize]
        //public ActionResult UpdateProduct(string _id,string _pname, string _price, string _pdescription)
        //{
        //    if(ModelState.IsValid)
        //    {
        //        ProductView pv = new ProductView() { Id=int.Parse(_id)  , ProductName = _pname, ProductProce = Convert.ToDecimal(_price), ProductDescription = _pdescription, UpdateBy = User.Identity.Name, UpdatedDate = DateTime.Now };
        //        ProductManager _manager = new ProductManager();

        //        _manager.UpdateProduct(pv);
        //        return RedirectToAction("ListProducts");
        //        //return Json(new { success = true });
        //    }
        //    return View();

        //}


        public ActionResult Edit(int id)
        {
            if(id==null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            ProductManager pm = new ProductManager();
            ProductView pv = pm.SelectProduct((int)id);
            if(pv==null)
            {
                return HttpNotFound();
            }
            return View(pv);
        }