public IQueryable <NSX> GetNSXs() { var _db = new ShoesStore.Models.GiayCT(); IQueryable <NSX> query = _db.NSXs; return(query); }
public IQueryable <Giay> GetGiays([QueryString("id")] int?mansx) { var _db = new ShoesStore.Models.GiayCT(); IQueryable <Giay> query = _db.Giays; if (mansx.HasValue && mansx > 0) { query = query.Where(p => p.MaNSX == mansx); } return(query); }
public IQueryable <Giay> GetChitiet([QueryString("maGiay")] int?magiay) { var _db = new ShoesStore.Models.GiayCT(); IQueryable <Giay> query = _db.Giays; if (magiay.HasValue && magiay > 0) { query = query.Where(p => p.MaGiay == magiay); } else { query = null; } return(query); }
public void UpdateShoppingCartDatabase(String cartId, ShoppingCartUpdates[] CartItemUpdates) { using (var db = new ShoesStore.Models.GiayCT()) { try { int CartItemCount = CartItemUpdates.Count(); List <GioHang> myCart = GetCartItems(); foreach (var cartItem in myCart) { // Lặp qua các hàng trong giỏ hàng for (int i = 0; i < CartItemCount; i++) { if (cartItem.Giay.MaGiay == CartItemUpdates[i].MaGiay) { if (CartItemUpdates[i].PurchaseQuantity < 1 || CartItemUpdates[i].RemoveItem == true) { RemoveItem(cartId, cartItem.MaGiay); } else { UpdateItem(cartId, cartItem.MaGiay, CartItemUpdates[i].PurchaseQuantity); } } } } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Database - " + exp.Message.ToString(), exp); } } }
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); } } }
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); } } }