public ActionResult Assign(string[] roles, string[] userGroups, string loginId) { IRoleDao roleDao = _memberShipFactory.CreateRoleDao(); IUserGroupDao userGroupDao = _memberShipFactory.CreateUserGroupDao(); User user = _memberShipFactory.CreateUserDao().GetByLoginId(loginId); user.Roles.Clear(); foreach (Role role in roleDao.GetRolesByIds(roles)) { user.Roles.Add(role); } user.UserGroups.Clear(); foreach (UserGroup ug in userGroupDao.GetUserGroups(userGroups)) { user.UserGroups.Add(ug); } _memberShipFactory.CreateUserDao().SaveOrUpdate(user); _memberShipFactory.CreateUserDao().Flush(); return(RedirectToAction("Index")); }