示例#1
0
 public static int AddCart(CartInfo cart, int userID)
 {
     if (userID > 0)
     {
         cart.ID = dal.AddCart(cart);
     }
     else
     {
         cart.ID = CartHelper.AddToCart(cart);
     }
     return(cart.ID);
 }
示例#2
0
        private void Fruit_Click(object sender, EventArgs e)
        {
            Button btn  = (Button)sender;
            IItem  item = new Fruit(btn.Text);

            cartFruit.AddCart(item);
            ShowCrat(labelFruit, cartFruit.GetCartText);
        }
示例#3
0
        public ActionResult AddToCart(int productID, int productQuantity)
        {
            Product product = new Product()
            {
                ProductID = productID,
                Quantity  = productQuantity
            };

            var res = icart.AddCart(product, userId);

            if (res == "Success")
            {
                this.Flash(Toastr.SUCCESS, "Alert", "Item Aded to Cart");
            }
            else
            {
                this.Flash(Toastr.SUCCESS, "Alert", "Error adding Item");

                TempData["Success"] = "An Error Occured";
            }
            return(RedirectToAction("Index", "Shop"));
        }
 //public Cart Pay(int? id, DateTime datetime, int ID)
 //{
 //    var pay = icart.Pay(id,datetime,ID);
 //    return pay;
 //}
 public void AddCart(int userid, int goodsid, int count, DateTime carttime, double price, int flag)
 {
     icart.AddCart(userid, goodsid, count, carttime, price, flag);
 }
示例#5
0
        public IActionResult Store(int id, int quantity)
        {
            if (HttpContext.Session.GetString("Username") == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            else
            {
                var currentProduct = _product.GetById(id);
                if (currentProduct.Available == false)
                {
                    HttpContext.Session.SetString("ERRORPRODUCT", "Sản phảm " + currentProduct.Name + " bạn muốn mua hiện đã hết hàng");
                    return(RedirectToAction("List"));
                }
                else
                {
                    HttpContext.Session.Remove("ERRORPRODUCT");

                    if (quantity != 0 || quantity != 1)
                    {
                        String userId = HttpContext.Session.GetString("Username");
                        var    cart   = _cart.GetCartByUser(userId, id);
                        if (cart != null)
                        {
                            cart.Quantity += quantity;
                            _cart.UpdateCart(cart);
                        }
                        else
                        {
                            cart          = new Cart();
                            cart.Product  = _product.GetById(id);
                            cart.Quantity = quantity;
                            // cart.Id = id;
                            cart.UserId = userId;
                            DateTime date = Convert.ToDateTime(DateTime.Now);
                            cart.DateBuy = date;
                            _cart.AddCart(cart);
                        }
                    }
                    else
                    {
                        // ListCart = new List<Cart>();
                        String userId = HttpContext.Session.GetString("Username");
                        var    cart   = _cart.GetCartByUser(userId, id);
                        if (cart != null)
                        {
                            cart.Quantity++;
                            _cart.UpdateCart(cart);
                        }
                        else
                        {
                            cart          = new Cart();
                            cart.Product  = _product.GetById(id);
                            cart.Quantity = 1;
                            // cart.Id = id;
                            cart.UserId = userId;
                            DateTime date = Convert.ToDateTime(DateTime.Now);
                            cart.DateBuy = date;
                            _cart.AddCart(cart);
                        }
                    }
                    return(RedirectToAction("List"));
                }
            }
        }
示例#6
0
文件: CartManage.cs 项目: braveHUI/-
 public static void AddCart(Cart carts)
 {
     cartss.AddCart(carts);
 }