public ActionResult CreateUser(UserViewModel model) { if (ModelState.IsValid) { UsersManager.CreateUser(model.UserName, model.Password, model.Email, model.RoleId); return RedirectToAction("Index", "Admin"); } return View(model); }
public ActionResult UserEdit(UserViewModel model) { if (ModelState.IsValid) { if (model.UserId >= 0) { if (model.UserName != model.PreviousUserName) ; UsersManager.ChangeUser(model.UserId, model.UserName, model.Password, model.Email, model.RoleId); return RedirectToAction("Index"); } } return View(model); }
public ActionResult UserEdit(int id) { User user = UsersManager.GetUser(id); if(user!=null) { UserViewModel userViewModel = new UserViewModel(); userViewModel.RoleId = user.RoleId; userViewModel.UserName = user.Login; userViewModel.Email = user.Email; userViewModel.UserId = id; userViewModel.PreviousUserName = user.Login; return View(userViewModel); } return RedirectToAction("Index", "Error"); }