Esempio n. 1
0
        internal static bool ConfirmDeleted(this DoAnTMDT_Entities _context, HttpContext httpContext, CookieServices _cookieServices, string orderID)
        {
            string cookie = _cookieServices.ReadCookie(httpContext, "CART_INFORMATION");

            if (cookie != null)
            {
                try
                {
                    var cartDetailsInDB = _context.CartDetailTable.Include(x => x.Product).Where(x => x.CartID == orderID).ToList();
                    foreach (var cartDetail in cartDetailsInDB)
                    {
                        _context.RemoveFromCart(httpContext, cartDetail.ProductID, cartDetail.Size, (byte)cartDetail.Quantity);
                    }
                    _context.Remove(_context.CartTable.Find(orderID));

                    _context.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 2
0
 public IActionResult RemoveCart(int itemID, string size, byte quantity = 1)
 {
     if (_context.RemoveFromCart(HttpContext, itemID, size, quantity))
     {
         return(RedirectToAction(nameof(Index)));
     }
     return(View(nameof(Error)));
 }