コード例 #1
0
 public ActionResult UserRoles(SelectUserRolesViewModel model)
 {
     if (ModelState.IsValid)
     {
         var idManager = new ClinikeIdentityManager();
         var user = ClinikeUserEx.Find(u => u.UserName == model.UserName);
         idManager.ClearUserRoles(user.Id);
         foreach (var role in model.Roles)
         {
             if (role.Selected)
             {
                 idManager.AddUserToRole(user.Id, role.Name);
             }
         }
         return RedirectToRoute("AccountIndex");
     }
     return View();
 }
コード例 #2
0
 public ActionResult UserRoles(string id)
 {
     var user = ClinikeUserEx.Find(u => u.Id == id, includes: new List<string> { "Roles" });
     var model = new SelectUserRolesViewModel(user);
     return View(model);
 }