Esempio n. 1
0
        public ActionResult DeleteFromCartList(int productid)
        {
            var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId);

            if (currentUserId > 0)
            {
                var cartProduct = _AddToCartBusiness.GetList(c => c.UserId == currentUserId && c.ProductId == productid).FirstOrDefault();
                if (cartProduct != null)
                {
                    _AddToCartBusiness.Delete(cartProduct);
                    _unitOfWork.SaveChanges();
                }
            }
            else
            {
                CookieStore mycookie           = new CookieStore();
                var         products           = mycookie.GetCookie(Enumerator.CustomerAction.AddToCart.ToString());
                var         productId          = productid.ToString();
                var         value              = mycookie.FormatCartCookieValueAfterDelete(products, productId);
                var         expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr"));
                mycookie.SetCookie(Enumerator.CustomerAction.AddToCart.ToString(), value, expireCookieTimeHr);
            }
            return(new EmptyResult());
        }