public ActionResult Create(MenuType collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuTypeDao bdDao = new MenuTypeDao(); if (bdDao.FindByID(collection.ID) == null) { UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.CreatedBy = us.UserName; collection.CreatedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } else { ModelState.AddModelError("", "Mã nhóm menu đã tồn tại"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
// GET: Admin/MenuType/Edit/5 public ActionResult Edit(string id) { MenuTypeDao bdDao = new MenuTypeDao(); return(View(bdDao.FindByID(id))); }