Exemplo n.º 1
0
        public void accept()
        {
            if (SelectedItem is User)
            {
                if (CurrentUser.isAdmin())
                {
                    if ((SelectedItem as User).privilege.Equals("admin"))
                    {
                        userRepository.changePrivelege((SelectedItem as User), "user");
                    }
                    else if ((SelectedItem as User).privilege.Equals("user"))
                    {
                        userRepository.changePrivelege((SelectedItem as User), "moderator");
                    }
                    else if ((SelectedItem as User).privilege.Equals("moderator"))
                    {
                        userRepository.changePrivelege((SelectedItem as User), "admin");
                    }

                    AlertWindow alertWindow = new AlertWindow($"Пользователь {(SelectedItem as User).firstName} {(SelectedItem as User).secondName} теперь {(SelectedItem as User).privilege}");
                    alertWindow.ShowDialog();
                }
                else
                {
                    AlertWindow alertWindow = new AlertWindow("У вас недостаточно прав для совершения данного действия");
                    alertWindow.ShowDialog();
                }
            }
            else if (SelectedItem is TmpAnnouncement)
            {
                transferToAnnouncemet(SelectedItem as TmpAnnouncement);
            }
            else
            {
                AlertWindow alertWindow = new AlertWindow($"Выберите объект");
                alertWindow.ShowDialog();
            }

            update();
        }