Exemple #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            for (int i = 0; i < userManager.Users.ToList().Count; i++)
            {
                var user = userManager.Users.ToList()[i];

                Console.WriteLine(user.Name);
                if (UserNames.Contains(user.Id))
                {
                    if (!await IsInRole(user))
                    {
                        await userManager.AddToRoleAsync(user, RoleName);
                    }
                }
                else
                {
                    if (await IsInRole(user))
                    {
                        await userManager.RemoveFromRoleAsync(user, RoleName);
                    }
                }
            }
            return(RedirectToPage("/AdminPages/ListRoles"));
        }
Exemple #2
0
        public MeetingViewModel(IRHDispatcher dispatcher, IServiceProvider serviceProvider, NavigationState navigationState, INavigation navigation)
        {
            _dispatcher      = dispatcher;
            _serviceProvider = serviceProvider;
            _navigationState = navigationState;
            _navigation      = navigation;
            token            = ConnectEvent.Instance.Subscribe((c) =>
            {
                lock (lockobj) //Synchronous
                {
                    if (c.Parms.ContainsKey("HostCode") && c.Parms["HostCode"] != null && ((string)c.Parms["HostCode"]).ToUpper() == HostCode)
                    {
                        switch (c.Method)
                        {
                        case "ReceiveUpdate":
                            _dispatcher.Invoke(Dispatcher, () => {
                                var newUserNames = (List <string>)c.Parms["UserNames"];
                                foreach (var newUser in newUserNames)
                                {
                                    if (!UserNames.Contains(newUser))
                                    {
                                        UserNames.Add(newUser);
                                    }
                                }
                                var removeUsers = new List <string>();
                                foreach (var existUser in UserNames)
                                {
                                    if (!newUserNames.Contains(existUser))
                                    {
                                        removeUsers.Add(existUser);
                                    }
                                }
                                foreach (var user in removeUsers)
                                {
                                    UserNames.Remove(user);
                                }
                            });
                            break;

                        case "ReceiveUpdateRaiseHands":
                            if (c.Parms.ContainsKey("HostCode"))
                            {
                                _dispatcher.Invoke(Dispatcher, () => {
                                    var RaisedHands = (List <string>)c.Parms["RaisedHands"];
                                    RaisedNames.Clear();
                                    foreach (var name in RaisedHands)
                                    {
                                        RaisedNames.Add(name);
                                    }
                                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("RaisedNames"));
                                });
                            }
                            break;

                        case "ReceiveCloseHost":
                            if (!IsHost)
                            {
                                var leaveparms = new Dictionary <string, object>();
                                leaveparms.Add("HostCode", HostCode);
                                leaveparms.Add("Name", Name);
                                leaveparms.Add("IsHost", IsHost);
                                ConnectEvent.Instance.Publish(new Connect()
                                {
                                    Method = "Set", Parms = leaveparms
                                });
                                _navigation.GoBack();
                            }
                            break;
                        }
                    }
                }
            });
            LoadedCommand    = new DelegateCommand(OnLoaded);
            LeaveCommand     = new DelegateCommand(OnLeave);
            RaiseHandCommand = new DelegateCommand <string>(OnRaiseHand);
        }