public ActionResult Create(UserAddViewModel model) { try { AddUserDto dto = new AddUserDto(); dto.UserName = model.UserName; dto.UserPassword = CommonTools.ToMd5(model.UserPassword); dto.UserRoles = "45"; dto.UserStatus = true; string userJsonString = JsonHelper.JsonSerializerBySingleData(dto); Message msg = CMSService.Insert("User", userJsonString); return RedirectTo("/User/Index", msg.MessageInfo); } catch { Message msg = new Message(); msg.MessageStatus = "Error"; msg.MessageInfo = "操作出错了"; ViewBag.Status = msg.MessageStatus; ViewBag.msg = msg.MessageInfo; return View(); } }
public ActionResult UserSignup(UserSignupViewModel model) { try { AddUserDto dto = new AddUserDto(); dto.UserName = model.UserName; dto.UserPassword = CommonTools.ToMd5(model.UserPassword); dto.UserRoles = model.UserRoles; dto.UserStatus = true; string userJsonString = JsonHelper.JsonSerializerBySingleData(dto); Message msg = CMSService.Insert("User", userJsonString); // return RedirectTo("/Login/Login", msg.MessageInfo); return RedirectToAction("Login", "Login", new { ac = "SignupSuccess" }); } catch { Message msg = new Message(); msg.MessageStatus = "Error"; msg.MessageInfo = "注册失败了"; ViewBag.Status = msg.MessageStatus; ViewBag.msg = msg.MessageInfo; return View("Login"); } }