Beispiel #1
0
        public ActionResult SPViewDM(int?id)
        {
            db = new LaptopStoreDB();
            DanhMuc dm = db.DanhMucs.Find(id);

            if (dm != null)
            {
                ViewBag.TenDM = dm.Tendanhmuc;
            }
            var sp = db.SanPhams.Where(p => p.DanhmucID == id);

            return(View(sp));
        }
Beispiel #2
0
        // GET: SanPham
        public ActionResult SanphamView(string keyword, int?page)
        {
            int pageNumber   = (page ?? 1);
            int itemsPerPage = 6;

            db = new LaptopStoreDB();

            var products = db.SanPhams.ToList();
            var pageSize = products.Count / itemsPerPage;

            var sp = products
                     .Where(p => p.SanphamID != null)
                     .OrderBy(p => p.Tensanpham)
                     .ToList();

            if (!string.IsNullOrEmpty(keyword) && !string.IsNullOrWhiteSpace(keyword))
            {
                sp = sp.Where(p => !string.IsNullOrEmpty(p.Tensanpham) && p.Tensanpham.ToLower().Contains(keyword.ToLower()))
                     .ToList();
            }
            return(View(sp.OrderBy(n => n.SanphamID).ToPagedList(pageNumber, itemsPerPage)));
        }
Beispiel #3
0
 public DonhangFunction()
 {
     db = new LaptopStoreDB();
 }
Beispiel #4
0
 public CartFunction()
 {
     context = new LaptopStoreDB();
 }
Beispiel #5
0
 public SanPhamFunction()
 {
     db = new LaptopStoreDB();
 }
Beispiel #6
0
 public DanhMucFunction()
 {
     db = new LaptopStoreDB();
 }
Beispiel #7
0
 public TaikhoanFunction()
 {
     context = new LaptopStoreDB();
 }