// GET: Admin/SanPham/Edit/5 public ActionResult Edit(int id) { var ds = ProductBus.ChiTiet(id); var selectnsx = ds.MaNSX; var selectlsp = ds.MaLSP; ViewBag.MaNSX = new SelectList(BrandBus.DanhSach(), "MaNSX", "TenNSX", selectnsx); ViewBag.MaLSP = new SelectList(TypeBus.DanhSach(), "MaLSP", "TenLSP", selectlsp); return(View(ds)); }
public ActionResult Edit(ProductViewModels sp) { try { var validImageTypes = new string[] { "image/gif", "image/jpeg", "image/pjpeg", "image/png" }; if (sp.ImageUpload2 == null || sp.ImageUpload2.ContentLength == 0) { ModelState.AddModelError("ImageUpload", "Chưa chọn hình"); } else if (!validImageTypes.Contains(sp.ImageUpload2.ContentType)) { ModelState.AddModelError("ImageUpload", "Làm ơn chọn file có định dạng hình GIF, JPG, PNG."); } if (ModelState.IsValid) { if (sp.ImageUpload2 != null && sp.ImageUpload2.ContentLength > 0) { var uploadDir = "~/Image/product"; var imagePath = Path.Combine(Server.MapPath(uploadDir), sp.ImageUpload2.FileName); var imageUrl = Path.Combine(uploadDir, sp.ImageUpload2.FileName); sp.ImageUpload2.SaveAs(imagePath); if (sp.ImageUpload2.FileName != null) { sp.Hinh = sp.ImageUpload2.FileName; } } } sp.NgayDangSP = DateTime.Now; ProductBus.Sua(sp); return(RedirectToAction("Index")); } catch { return(View(ProductBus.ChiTiet(sp.MaSP))); } }
// // GET: /Admin/AminProduct/Edit/5 public ActionResult Edit(string id) { return(View(ProductBus.ChiTiet(id))); }
public ActionResult Details(string id) { Session["MaSP"] = id; return(View(ProductBus.ChiTiet(id))); }