Beispiel #1
0
 public ActionResult UserRoles(SelectUserRolesViewModel model)
 {
     if (ModelState.IsValid)
     {
         var idManager = new IdentityManager();
         var Db = new ApplicationDbContext();
         var user = Db.Users.First(u => u.UserName == model.UserName);
         idManager.ClearUserRoles(user.Id);
         foreach (var role in model.Roles)
         {
             if (role.Selected)
             {
                 idManager.AddUserToRole(user.Id, role.RoleName);
             }
         }
         return RedirectToAction("index");
     }
     return View();
 }
Beispiel #2
0
 public ActionResult UserRoles(string id)
 {
     var Db = new ApplicationDbContext();
     var user = Db.Users.First(u => u.UserName == id);
     var model = new SelectUserRolesViewModel(user);
     return View(model);
 }