示例#1
0
 public void UpdateItem(string CapnhatMaGH, int CapNhatMagiay, int
                        quantity)
 {
     using (var _db = new ShoesStore.Models.GiayCT())
     {
         try
         {
             var myItem = (from c in _db.MuaHang
                           where c.MaGiohang == CapnhatMaGH && c.Giay.MaGiay ==
                           CapNhatMagiay
                           select c).FirstOrDefault();
             if (myItem != null)
             {
                 myItem.SoLuong = quantity;
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Update Cart Item - " +
                                 exp.Message.ToString(), exp);
         }
     }
 }
示例#2
0
 public void RemoveItem(string removeMaGH, int removeMaGiay)
 {
     using (var _db = new ShoesStore.Models.GiayCT())
     {
         try
         {
             var myItem = (from c in _db.MuaHang
                           where c.MaGiohang == removeMaGH && c.Giay.MaGiay ==
                           removeMaGiay
                           select c).FirstOrDefault();
             if (myItem != null)
             {
                 // Xóa
                 _db.MuaHang.Remove(myItem);
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Remove Cart Item - " +
                                 exp.Message.ToString(), exp);
         }
     }
 }