示例#1
0
        public IQueryable <NSX> GetNSXs()
        {
            var _db = new ShoesStore.Models.GiayCT();
            IQueryable <NSX> query = _db.NSXs;

            return(query);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 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);
         }
     }
 }
示例#5
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);
         }
     }
 }
示例#6
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);
         }
     }
 }