public void UbahItem(string ubahCartID, int ubahProdukID, int jumlah) { using (var _db = new TokoTelevisiOnline.model.ProdukContext()) { try { var myItem = (from c in _db.DataShoppingCart where c.CartId == ubahCartID && c.Produk.ProdukId == ubahProdukID select c).FirstOrDefault(); if (myItem != null) { myItem.Jumlah = jumlah; _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Updte cart Item - " + exp.Message.ToString(), exp); } } }
public void HapusItem(string hapusCartID, int hapusProdukID) { using (var _db = new TokoTelevisiOnline.model.ProdukContext()) { try { var myItem = (from c in _db.DataShoppingCart where c.CartId == hapusCartID && c.Produk.ProdukId == hapusProdukID select c).FirstOrDefault(); if (myItem != null) { _db.DataShoppingCart.Remove(myItem); _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Cart Item tidak berhasil dihapus " + exp.Message.ToString(), exp); } } }