public ActionResult Create(UserCreateRequest model) { if (ModelState.IsValid == false) { return View(model); } if (_userManageService.ExistsUser(model.UserName) == false) { _userManageService.Create(new User { UserName = model.UserName, UserPwd = model.Password.ToMd5(), Nick = model.Nick, CreateTime = DateTime.Now, IsEnable = model.IsEnable }); return RedirectToAction("Index"); } ModelState.AddModelError("_error", "登录账号已存在"); return View(model); }
public ActionResult Create(UserCreateRequest model) { var userPwdHash = model.Password.ToMd5(); if (!_userManageService.ExistsUser(model.UserName)) { _userManageService.Create(new User { UserName = model.UserName, UserPwd = userPwdHash, Nick = model.Nick, CreateTime = DateTime.Now }); return RedirectToAction("Index"); } ModelState.AddModelError("_error", "登录账号已存在"); return View(); }
public ActionResult Create() { var viewModel = new UserCreateRequest {IsEnable = true}; return View(viewModel); }