示例#1
0
 public void AddCartBeforeLogoff(string userId)
 {
     if (HttpContext.Current.Session["Cart"] != null)
     {
         var db = new GemmaDBContext();
         foreach (var item in (List <Cart>)HttpContext.Current.Session["Cart"])
         {
             ShoppingCart shoppingCart = new ShoppingCart
             {
                 CustomerID = userId,
                 ProductID  = item.ProductID,
                 ColorID    = item.ColorID,
                 Quantity   = item.Quantity,
                 SizeID     = item.SizeID,
             };
             db.ShoppingCarts.Add(shoppingCart);
         }
         db.SaveChanges();
     }
 }