Example #1
0
        public ActionResult DeleteItemInCart(FormCollection form)
        {
            int userID          = Convert.ToInt32(Session["userID"]);
            int saleOrderItemID = Convert.ToInt32(form["buttonDelete"].ToString());

            _saleOrderItemService.UpdateStatusObject(saleOrderItemID);
            ARSaleOrder objsaleOrder = _saleOrderService.GetObjectByItemID(saleOrderItemID);

            if (objsaleOrder != null)
            {
                _saleOrderService.UpdateTotalAmount(objsaleOrder);
            }
            Session["CartItemQty"] = Convert.ToInt32(Session["CartItemQty"]) - _saleOrderItemService.GetSaleOrderItemQuantity(saleOrderItemID);
            return(RedirectToAction("ShowCartsOfUser", "Cart"));
        }
Example #2
0
        public ActionResult AddProductToCartValidateQty(int productID)
        {
            if (Session["token"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            int userID = Convert.ToInt32(Session["userID"]);

            if (_saleOrderService.CheckSaleOrderCurrentInUser(userID) != null)
            {
                var saleOrder = _saleOrderService.CheckSaleOrderCurrentInUser(userID);
                if (_saleOrderServiceItem.CheckExistingProductInListCart(userID, productID) != null)
                {
                    var saleOrderitem = _saleOrderServiceItem.CheckExistingProductInListCart(userID, productID);
                    saleOrderitem.ARSaleOrderItemQty += 1;
                    _saleOrderServiceItem.UpdateTotalAmount(saleOrderitem);
                    _saleOrderServiceItem.UpdateObject(saleOrderitem);
                }
                else
                {
                    _saleOrderServiceItem.CreateObject(saleOrder.ARSaleOrderID, productID);
                }
                _saleOrderService.UpdateTotalAmount(saleOrder);
            }
            else
            {
                int saleOrderID = _saleOrderService.CreateObject(userID, productID);
                _saleOrderServiceItem.CreateObject(saleOrderID, productID);
            }
            int cartItemQty = Convert.ToInt32(Session["CartItemQty"]) + 1;

            Session["CartItemQty"] = cartItemQty;
            int furnitureTypeGroupID = Convert.ToInt32(Session["FurnitureTypeGroupID"]);

            return(RedirectToAction("Filter", "FurnitureType", new { id = furnitureTypeGroupID }));
        }