// GET: Sanpham/Details/5 public ActionResult Details(int id) { DbSanPham dbsp = new DbSanPham(); var data = dbsp.GetOneRow(id); return(View(data)); }
public ActionResult Create(SanPham sp) { if (ModelState.IsValid) { try { // TODO: Add insert logic here HttpPostedFileBase File = Request.Files["AnhSanPham"]; string path = Server.MapPath("~/Images/Sanpham/" + File.FileName); string img_url = "Images/Sanpham/" + File.FileName; File.SaveAs(path); sp.AnhSanPham = img_url; DbSanPham db = new DbSanPham(); db.AddNew(sp); return(RedirectToAction("Index")); } catch { return(View()); } } else { return(View()); } }
// GET: Sanpham public ActionResult Index() { DbSanPham dbsp = new DbSanPham(); var data = dbsp.GetAllRow(); return(View(data)); }