// GET: ManageProduct/Delete
        public ActionResult Delete(int id)
        {
            var pD = CSDLQLBH.GetSingleProduct(id);

            if (pD != null)
            {
                CSDLQLBH.RemoveProduct(id);
            }
            Ulti.DeleteProductImgs(id, Server.MapPath("~"));
            return(RedirectToAction("Index"));
        }
        public ActionResult Detail(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var product = CSDLQLBH.GetSingleProduct(id);
            List <ClientComment> listCom = CSDLQLBH.GetCommentsByProduct(product.ProID).ToList();

            if (listCom != null)
            {
                ViewBag.ListComment = listCom;
            }
            return(View(product));
        }
        //bấm nút thanh toán, nó sẽ lưu vào csdl và giỏ hàng sẽ trở về số 0
        public ActionResult Checkout(decimal totalPrice)
        {
            var c  = Session["cart"] as ClientCart;
            var ui = Session["Logged"] as ClientUserInfo;

            var user  = CSDLQLBH.UserGetSingleByUserName(ui.Username);
            var order = new ClientOrder
            {
                OrderDate = DateTime.Now,
                User      = user,
                Total     = totalPrice,
            };

            var totalOrders = CSDLQLBH.GetOrders().ToList().Count;

            if (totalOrders == 0)
            {
                order.OrderID = 1;
            }
            CSDLQLBH.InsertOrders(order);

            decimal amount = 0;

            foreach (var ci in c.Items)
            {
                var p = CSDLQLBH.GetSingleProduct(ci.Product.ProID);
                amount = (decimal)p.Price * ci.Quantity;
                var od = new ClientOrderDetail
                {
                    Order    = order,
                    Product  = p,
                    Quantity = ci.Quantity,
                    Price    = (decimal)p.Price,
                    Amount   = amount
                };
                CSDLQLBH.InsertOrderDetail(od);
                p.Quantity -= ci.Quantity;
                CSDLQLBH.UpdateProduct(p);
            }

            c = CSDLQLBH.Checkout(c);
            Session["CheckOut"] = 1;
            return(RedirectToAction("Detail", "Cart"));
        }