Exemplo n.º 1
0
 public void UpdateItem(string updateCartID, int updateProductID, int quantity)
 {
     using (var _db = new store.Models.ProductContext())
     {
         try
         {
             var myItem = (from c in _db.ShoppingCartProducts where c.CartId == updateCartID && c.Product.ProductID == updateProductID select c).FirstOrDefault();
             if (myItem != null)
             {
                 myItem.Quantity = quantity;
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("Unable to Update Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }
Exemplo n.º 2
0
 public void RemoveItem(string removeCartID, int removeProductID)
 {
     using (var _db = new store.Models.ProductContext())
     {
         try
         {
             var myItem = (from c in _db.ShoppingCartProducts where c.CartId == removeCartID && c.Product.ProductID == removeProductID select c).FirstOrDefault();
             if (myItem != null)
             {
                 _db.ShoppingCartProducts.Remove(myItem);
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }