public ActionResult Create(NhomSanPham collection) { var session = (UserSession)Session[CommonConstant.USER_SESSION]; collection.CreateBy = session.UserName; collection.CreateDate = DateTime.Now; if (ModelState.IsValid) { var dao = new NhomsanphamDao(); long id = dao.Insert(collection); if (id > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", CommonConstant.INSERT_FAIL); } } else { ModelState.AddModelError("", CommonConstant.INSERT_FAIL); } return(View("Index")); }
public ActionResult Index(string searchKey, int page = 1, int pagesize = 10) { var nhomsp = new NhomsanphamDao(); if (!string.IsNullOrEmpty(searchKey)) { var lst = nhomsp.SearchResult(searchKey, page, pagesize); return(View(lst)); } else { var model = nhomsp.ListAll(page, pagesize); return(View(model)); } }
public ActionResult Edit(NhomSanPham cate) { if (ModelState.IsValid) { var dao = new NhomsanphamDao(); var res = dao.Update(cate); if (res) { return(RedirectToAction("Index", "NhomSanPham")); } else { ModelState.AddModelError("", CommonConstant.UPDATE_FAIL); } } return(View("Index")); }
// GET: admin/NhomSanPham/Edit/5 public ActionResult Edit(int id) { var cate = new NhomsanphamDao().ViewDetail(id); return(View(cate)); }