public ActionResult CreateUsers(Users eUsers) { if (ModelState.IsValid) { try { string message = ""; if (eUsers.Password == eUsers.ConfirmPassword) { eUsers.Password = encryption(eUsers.Password); FASM_Enums.InfoMessages SaveResult = UsersBI.SaveUsers(ref eUsers); switch (SaveResult) { case FASM_Enums.InfoMessages.Success: message = "Successfully created!"; break; case FASM_Enums.InfoMessages.AlreadyExist: message = "The username already exist!"; break; } } else { message = "Password does not match confirm password"; } return(Json(new { msg = message, JsonRequestBehavior.AllowGet })); } catch (Exception ex) { ViewBag.CatchedMsg = ex.Message; } } return(View(eUsers)); }
public ActionResult EditUsers(Users eUsers) { if (eUsers.isLoad == false) { eUsers.UserId = Convert.ToInt32(Request.Params["UserId"]); UsersBI.LoadUsers(ref eUsers); return(PartialView(eUsers)); } else { if (ModelState.IsValid) { try { string message = ""; FASM_Enums.InfoMessages SaveResult = UsersBI.SaveUsers(ref eUsers); switch (SaveResult) { case FASM_Enums.InfoMessages.Success: message = FASM_Msg.Updated; break; case FASM_Enums.InfoMessages.AlreadyExist: message = "The username already exist!"; break; } return(Json(new { msg = message, JsonRequestBehavior.AllowGet })); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } } return(View()); }
public ActionResult Register(Users eUsers) { if (ModelState.IsValid) { try { if (eUsers.Password == eUsers.ConfirmPassword) { eUsers.Password = encryption(eUsers.Password); FASM_Enums.InfoMessages SaveResult = UsersBI.SaveUsers(ref eUsers); switch (SaveResult) { case FASM_Enums.InfoMessages.Success: ModelState.AddModelError("Success", "Successfully created!"); ViewBag.ReturnMsg = "Success"; break; case FASM_Enums.InfoMessages.AlreadyExist: ModelState.AddModelError("Success", "The username already exist!"); ViewBag.ReturnMsg = "Failed"; break; } } else { ModelState.AddModelError("Success", "Password does not match confirm password"); ViewBag.ReturnMsg = "Failed"; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return(View(eUsers)); }