public ActionResult Regis(USER User, HttpPostedFileBase Picture) { if (ModelState.IsValid || User.PASSWORD != null || !User.PASSWORD.Equals("")) { if (userModels.CheckEmail(User.EMAIL)) { //upload file if (Picture != null && Picture.ContentLength > 0) { var path = Server.MapPath("~/Assets/Upload/User/"); ImgUpload imgUpload = new ImgUpload(); User.PICTURE = imgUpload.Upload(Picture, path); } User.ACTIVE = false; User.ID_ROLE = roleModels.GetItemName(ConstanAppkey.USER()).ID; if (userModels.AddItem(User) > 0) { Session["mes_su"] = "Đăng ký thành công. chờ xét duyệt"; return(RedirectToAction("Index", "Login")); } else { Session["mes_er"] = "Đăng ký thất bại, thử lại!"; return(RedirectToAction("Regis", "Login")); } } else { Session["mes_er"] = "Email đã đăng ký!!!"; } } return(RedirectToAction("Regis", "Login")); }
public ActionResult Add(USER UserR, FormCollection form, HttpPostedFileBase Picture) { if (Check.checkUserAdd(UserR)) { if (ModelState.IsValid || UserR.PASSWORD != null || !UserR.PASSWORD.Equals("")) { if (userModels.CheckEmail(UserR.EMAIL)) { //upload file if (Picture != null && Picture.ContentLength > 0) { var path = Server.MapPath("~/Assets/Upload/User/"); ImgUpload imgUpload = new ImgUpload(); UserR.PICTURE = imgUpload.Upload(Picture, path); } if (this.Request.Form["ACTIVE"] != null) { UserR.ACTIVE = true; } else { UserR.ACTIVE = false; } if (userModels.AddItem(UserR) > 0) { Session["mes"] = "Thêm thành công!!!"; } else { Session["mes_er"] = "Thêm thất bại!!!"; } return(RedirectToAction("Index", "UserManager")); } else { Session["mes_er"] = "Email đã đăng ký!!!"; } } } ViewBag.ListRole = roleModels.GetAllItems(); return(View(UserR)); }