Exemple #1
0
 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);
 }
Exemple #2
0
 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);
 }
Exemple #3
0
 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");
 }