public void UpdateItem(string updateCartID, int updateProductID, int quantity) { // using (webformsstorefrontEntities db = new webformsstorefrontEntities()) using (var db = new scifiBookStore.BLL.Model.ProductContext()) { try { var myItem = (from c in db.ShoppingCartItems 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("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp); } } }
public void RemoveItem(string removeCartID, int removeProductID) { using (var db = new scifiBookStore.BLL.Model.ProductContext()) { try { var myItem = (from c in db.ShoppingCartItems where c.CartId == removeCartID && c.Product.productID == removeProductID select c).FirstOrDefault(); if (myItem != null) { // db.DeleteObject(myItem); db.ShoppingCartItems.Remove(myItem); db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp); } } }