public ActionResult Edit(Thucpham thucpham) { if (ModelState.IsValid) { var dao = new ThucphamDao(); thucpham.MetaTitle = VietNamChar.ReplaceUnicode(thucpham.Ten_thucpham); var result = dao.Update(thucpham); if (result) { return(RedirectToAction("Index", "Thucpham")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); } } return(View("Index")); }
public ActionResult Create(Thucpham thucpham) // Tạo tài khoản { if (ModelState.IsValid) { var dao = new ThucphamDao(); thucpham.MetaTitle = VietNamChar.ReplaceUnicode(thucpham.Ten_thucpham); long id = dao.Insert(thucpham); if (id > 0) { return(RedirectToAction("Index", "Thucpham")); } else { ModelState.AddModelError("", "Thêm không thành công"); } } return(View("Index")); }