public ActionResult Index(int?page) { var LstDS = SPBUS.LoadTop10SP(); int pageSize = 12; int pageNumber = (page ?? 1); return(View(LstDS.ToPagedList(pageNumber, pageSize))); }
//Load Sản phẩm theo loại public ActionResult SPLoai(int id, int?page) { var LstDS = SPBUS.LoadDSLoaiSP(id); int pageSize = 6; int pageNumber = (page ?? 1); return(View(LstDS.ToPagedList(pageNumber, pageSize))); }
public ActionResult Create(SP n) { // TODO: Add insert logic here ViewBag.NhaSX = NSXBUS.DanhSach(); ViewBag.Loai = LoaiSPBUS.LoadDSLoaiSP(); if (ModelState.IsValid) { try { if (HttpContext.Request.Files.Count > 0) { var hpf = HttpContext.Request.Files[0]; if (hpf.ContentLength > 0) { string fileName = Guid.NewGuid().ToString(); string fullPathWithFileName = "/Assets/Images/products/" + fileName + ".jpg"; hpf.SaveAs(Server.MapPath(fullPathWithFileName)); n.HinhAnh = fullPathWithFileName; var b = new SanPham() { idSP = n.idSP, GiaSP = n.GiaSP, HinhAnh = n.HinhAnh, MaLoai = n.MaLoai, TenSP = n.TenSP, MaNSX = n.MaNSX, MoTa = n.MoTa }; SPBUS.ThemSP(b); return(RedirectToAction("Index")); } else { return(View()); } } else { return(View()); } } catch { return(View()); } } else { return(View()); } }
// GET: Admin/NhaSX/Edit/5 public ActionResult Edit(int id) { ViewBag.NhaSX = NSXBUS.DanhSach(); ViewBag.Loai = LoaiSPBUS.LoadDSLoaiSP(); ////////// var b = SPBUS.LoadSanPham(id); var a = new SP() { HinhAnh = b.HinhAnh, idSP = b.idSP, GiaSP = int.Parse(b.GiaSP.ToString()), MaLoai = int.Parse(b.MaLoai.ToString()), MaNSX = int.Parse(b.MaNSX.ToString()), MoTa = b.MoTa, TenSP = b.TenSP }; return(View(a)); }
// GET: Admin/NhaSX/Delete/5 public ActionResult Delete(int id) { SPBUS.XoaSP(id); return(RedirectToAction("Index")); }
// GET: Admin/NhaSX public ActionResult Index() { return(View(SPBUS.LoadDSSP())); }
public ActionResult Item(int id) { return(View(SPBUS.LoadTop3SP())); }