Exemplo n.º 1
0
        public IActionResult Search([FromQuery] string Search, [FromQuery] int?page)
        {
            var pageNumber = page == null || page <= 0 ? 1 : page.Value;
            var users      = _userManager.Users
                             .Where(s => s.UserName.Contains(Search) ||
                                    s.Name.Contains(Search) ||
                                    s.PhoneNumber.Contains(Search) ||
                                    s.Surname.Contains(Search) ||
                                    s.UserName.Contains(Search))
                             .Select(user => new UserManagementIndexViewModel
            {
                Id             = user.Id,
                Username       = user.UserName,
                Name           = user.Name,
                Surname        = user.Surname,
                ImageUrl       = user.ImageUrl,
                DateRegistered = user.DateRegistered.ToLongDateString()
            });
            var model = new UserManagementListViewModel
            {
                Search = Search,
                Users  = new PagedList <UserManagementIndexViewModel>(users, pageNumber, 12)
            };

            return(View(model));
        }
Exemplo n.º 2
0
        //assigning data at the window startup
        /// <summary>
        /// FALSE = new user / TRUE = modify user
        /// </summary>
        /// <param name="mode"></param>
        private void AssignStartupData(bool mode, UserManagementListViewModel usermodel)
        {
            if (!mode) //new user creation
            {
                UserNameText  = "";
                PasswordText1 = "";
                PasswordText2 = "";

                _selectedLevel   = null;
                _selectedTimeout = null;
            }
            else
            {
                UserNameText  = usermodel.UserName;
                PasswordText1 = "********";
                PasswordText2 = "********";

                SelectedLevel   = AccessLevelList.Where(x => x.AccessLevel == usermodel.AccessLevel).First();
                SelectedTimeout = TimeoutList.Where(x => x.Minutes == usermodel.LogoutTime).First();

                _logger.Info($"In the existing user modification mode, assigned access level: {SelectedLevel.AccessLevel.ToString()}, user name: {UserNameText}.");

                AutomaticLogOff = usermodel.LogoutEnabled;

                AssignLanguagePrevillages(usermodel.LanguageEditionCode);
            }
        }
Exemplo n.º 3
0
        //constructor - moddifying existing user
        public UserCreatorViewModel(List <LanguageItemModel> languagesList,
                                    UserManagementListViewModel usermodel, int amointOfAdmins, IRealmProvider realmProvider)
        {
            _logger = NLog.LogManager.GetCurrentClassLogger();

            _realmProvider       = realmProvider;
            _windowMode          = true; //modify user
            _modificatedPlayerID = usermodel.UserID;
            CommonConstructorsMethod(languagesList);
            AssignStartupData(true, usermodel);
            DisableUserNameAndPasswordBoxes(false);
            EnableOrDisableAccessLevelChoice((amointOfAdmins >= 2 && usermodel.AccessLevel == AccessLevelEnum.Administrator) ||
                                             usermodel.AccessLevel != AccessLevelEnum.Administrator);

            _logger.Info($"User creator window created. Mode - modifyiing of existing user.");
        }
Exemplo n.º 4
0
        public IActionResult Index(int?page)
        {
            var pageNumber = page == null || page <= 0 ? 1 : page.Value;
            var users      = _userManager.Users.Select(user => new UserManagementIndexViewModel
            {
                Id             = user.Id,
                Username       = user.UserName,
                Name           = user.Name,
                Surname        = user.Surname,
                ImageUrl       = user.ImageUrl,
                DateRegistered = user.DateRegistered.ToLongDateString()
            });

            var model = new UserManagementListViewModel
            {
                Users = new PagedList <UserManagementIndexViewModel>(users, pageNumber, 12)
            };

            return(View(model));
        }
        //button that allows to modify any user, including currently logged one
        public void ModifyUserDefinition(int userID)
        {
            _logger.Info($"Procedure of modification of data of existing user with ID = {userID}, started.");

            try
            {
                UserManagementListViewModel modifiedUserModel = Users.Single(x => x.UserID == userID);
                int amountOfAdmins = Users.Where(x => x.AccessLevel == AccessLevelEnum.Administrator).ToList().Count;

                UserCreatorViewModel ucvm = new UserCreatorViewModel(_runtimeData.CustomLanguageList,
                                                                     modifiedUserModel, amountOfAdmins, _realmProvider);
                _manager.ShowDialog(ucvm);
                ReadAllUserDataFromDB();
            }
            catch (Exception ex)
            {
                _logger.Info($"Modification of existing user data wifn ID: {userID}, went wrong!");
                _logger.Info($"Error while trying to open user modification window: {ex.Message}.");
                MessageBox.Show("Couldn't open user modification window.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }