Пример #1
0
        // GET: Cart/Details/5
        public ActionResult Details(int id)
        {
            ProductDBHandle productModel = new ProductDBHandle();

            productModel.GetProduct();
            if (Session["cart"] == null)
            {
                List <Item> cart = new List <Item>();

                cart.Add(new Item {
                    book = productModel.find(id), Quantity = 1
                });
                Session["cart"] = cart;
            }
            else
            {
                List <Item> cart  = (List <Item>)Session["cart"];
                int         index = isExist(id);
                if (index != -1)
                {
                    cart[index].Quantity++;
                }
                else
                {
                    cart.Add(new Item {
                        book = productModel.find(id), Quantity = 1
                    });
                }
                Session["cart"] = cart;
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // GET: Product
        public ActionResult Index()
        {
            ProductDBHandle dbhandle = new ProductDBHandle();

            ModelState.Clear();
            return(View(dbhandle.GetProduct()));
        }
Пример #3
0
 public ActionResult Edit(int id, Book bmodel)
 {
     try
     {
         ProductDBHandle pdb = new ProductDBHandle();
         pdb.UpdateDetails(bmodel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #4
0
        // GET: Admin/Delete/5


        public ActionResult Delete(int id)
        {
            try
            {
                ProductDBHandle pdb = new ProductDBHandle();
                if (pdb.DeleteProduct(id))
                {
                    ViewBag.AlertMsg = "Product Deleted Successfully";
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #5
0
        public ActionResult Create(Orders order)
        {
            try
            {
                ProductDBHandle pdb = new ProductDBHandle();
                if (pdb.AddOrder(order))
                {
                    ViewBag.Message = "Order Details Added Successfully";
                    ModelState.Clear();
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }
Пример #6
0
 public ActionResult Create(Book bmodel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ProductDBHandle pdb = new ProductDBHandle();
             if (pdb.AddProduct(bmodel))
             {
                 ViewBag.Message = "Product Details Added Successfully";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Пример #7
0
        // GET: Product/Details/5
        public ActionResult Details(int id)
        {
            ProductDBHandle sdb = new ProductDBHandle();

            return(View(sdb.GetProduct().Find(smodel => smodel.Id == id)));
        }
Пример #8
0
        // GET: Admin/Edit/5

        public ActionResult Edit(int id)
        {
            ProductDBHandle pdb = new ProductDBHandle();

            return(View(pdb.GetProduct().Find(bmodel => bmodel.Id == id)));
        }