public void UpdateUserInRole(long id, long roleId)
        {
            using (var uow = new UnitOfWork())
            {
                List<UserInRole> userInRoles = new List<UserInRole>();
                var userInRole = uow.GetRepository<UserInRole>().Items.FirstOrDefault(x => x.UserId == id && roleId == roleId);
                if (userInRole.IsNotNull())
                    return;
                var userInRoleModel = new UserInRole()
                {
                    UserId = id,
                    RoleId = roleId,
                    Active = true
                };
                userInRoles.Add(userInRoleModel);
                AddUserInRole(userInRoles);

            }
        }
 public ActionResult UserInRole(UserInRoleViewModel userInRoleVM, string buttonType)
 {
     if (buttonType == "Next")
         return RedirectToAction("Index", "Dashboard");
     ValidateUserInRoleVM(userInRoleVM);
     List<UserInRole> userInRoleLst = new List<UserInRole>();
     if (ModelState.IsValid)
     {
         foreach (var userId in userInRoleVM.UsersSelected)
         {
             var userInRole = new UserInRole()
             {
                 RoleId = userInRoleVM.RoleId,
                 UserId = userId.As<long>(),
                 Active = true
             };
             userInRoleLst.Add(userInRole);
         }
         _wcfService.InvokeService<IOrganizationService>((svc) => svc.AddUserInRole(userInRoleLst));
         userInRoleVM.CreationSuccessful = true;
         userInRoleVM.Message = "Thank you for choosing the user(s) for the role '{0}'".ToFormat(userInRoleVM.RoleName);
     }
     return View(userInRoleVM);
 }