public ActionResult Create(Model.EF.Admin admin) { var session = (AdminLogin)Session[CommonConstants.USER_SESSION]; if (session.id_permission != 1) { return(View("Error")); } ViewBag.AdminName = session.name; if (ModelState.IsValid) { var dao = new AdminDao(); if (dao.IsUserNameExist(admin.username)) { ModelState.AddModelError("", "Tên đăng nhập đã tồn tại."); } else { var encryptedMd5Pas = Encryptor.MD5Hash(admin.password); admin.password = encryptedMd5Pas; int id = dao.Insert(admin); if (id > 0) { //để thông báo thêm thành công SetNotice("Hệ thống đã thêm thành công.", "success"); return(RedirectToAction("Create")); } else { ModelState.AddModelError("", "Thêm tài khoản không thành công."); } } } return(View()); }
public ActionResult Create(QuanTri entity) { if (ModelState.IsValid) { var dao = new AdminDao(); string TTK = dao.Insert(entity); if (TTK.Length > 0) { return(RedirectToAction("Index", "Admin")); } else { ModelState.AddModelError("", "Thêm Người Quản Trị Thành Công"); } } return(View("Index")); }
public ActionResult Create(AdminUser admin) { if (ModelState.IsValid) { var dao = new AdminDao(); long id = dao.Insert(admin); if (id > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index", "UserAdmin")); } else { ModelState.AddModelError("", "Thêm user thất bại"); } } return(View("Index")); }