Ejemplo n.º 1
0
        /// <summary>
        /// 删除商品
        /// </summary>
        private void Remove(HttpContext context)
        {
            int         id          = Convert.ToInt32(context.Request.Form["id"]);
            CartManager cartManager = new CartManager();

            cartManager.Delete(id);
            context.Response.Write("ok");
        }
Ejemplo n.º 2
0
        public ActionResult DeleteMyCart(int id)
        {
            CartManager cartManager = Session["cart"] as CartManager;

            cartManager.Delete(id);

            return(RedirectToAction("ListMyCarts"));
        }
Ejemplo n.º 3
0
        public IHttpActionResult Delete(Cart cart)
        {
            try
            {
                var mng = new CartManager();
                mng.Delete(cart);
                apiResp         = new ApiResponse();
                apiResp.Message = "";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
Ejemplo n.º 4
0
        public void sepetten_ürün_çıkarabilmeliyiz()
        {
            //Arrange
            //initialize
            //ürünü ekledik
            //sepetteki ürünleri saydık
            var sepettekiElemanSayisi = _cartManager.TotalItems;

            //Act
            //ürünü sildik
            //sepetteki ürünleri saydık
            _cartManager.Delete(1);
            var sepetteKalanElemanSayisi = _cartManager.TotalItems;

            //Assert
            Assert.AreEqual(sepettekiElemanSayisi - 1, sepetteKalanElemanSayisi);
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            //通过索引器来访问对象的值

            //有的时候代码有一个换行 有一个排版 看起来就会舒服很多
            string action = context.Request["action"];

            if (action == "edit")
            {
                int         count       = Convert.ToInt32(context.Request["count"]);
                int         cartId      = Convert.ToInt32(context.Request["cartId"]);
                CartManager cartManager = new CartManager();
                //最简单 也是最核心就是 修改用户购物中商品的数量

                //通过分层的话 更新数据都是先找到这条数据 着样有什么好处

                Cart cart = cartManager.GetModel(cartId);
                cart.Count = count;
                cartManager.Update(cart);

                //如果删除过更新失败出异常的话 会有一个统一的异常处理
                //所以那些判断其实也是就没有太大的必要了。
                context.Response.Write("ok");
            }
            else if (action == "delete")
            {
                //删除购物车列表中 用户选购的商品
                int         cartId      = Convert.ToInt32(context.Request["cartId"]);
                CartManager cartManager = new CartManager();
                cartManager.Delete(cartId);
                context.Response.Write("ok");
            }
            else
            {
                context.Response.Write("no");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request["action"];

            if (action == "edit")
            {
                int         count       = Convert.ToInt32(context.Request["count"]);
                int         cartId      = Convert.ToInt32(context.Request["cartId"]);
                CartManager cartManager = new CartManager();
                Cart        cartModel   = cartManager.GetModel(cartId);
                cartModel.Count = count;
                cartManager.Update(cartModel);
                context.Response.Write("ok");
            }
            else if (action == "delete")
            {
                int         cartId      = Convert.ToInt32(context.Request["cartId"]);
                CartManager cartManager = new CartManager();
                cartManager.Delete(cartId);
                context.Response.Write("ok");
            }//context.Response.Write("Hello World");
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 根据购物车id从购物车中删除一项
 /// </summary>
 /// <param name="recordId"></param>
 public void RemoveFromCart(int recordId)
 {
     cm.Delete(recordId);
 }
Ejemplo n.º 8
0
 public ActionResult Delete(int CartID)
 {
     cartmanager.Delete(CartID);
     return(Content("<script>alert('删除成功');window.location.href='../Mall/Cart';</script>"));
 }