Beispiel #1
0
        public List <UserManagementListViewModel> ToViewModelConverter(List <UserDefinition> userDefinition)
        {
            List <UserManagementListViewModel> outputList = new List <UserManagementListViewModel>();

            foreach (var item in userDefinition)
            {
                AccesLevelConverter converter = new AccesLevelConverter();

                UserManagementListViewModel newData = new UserManagementListViewModel()
                {
                    UserID              = item.Identity,
                    UserName            = item.UserName,
                    AccessLevel         = converter.GetAccesLevelEnum(item.AccessLevel),
                    AccessLevelString   = converter.GetAccesLevelEnum(item.AccessLevel).ToString(),
                    LogoutEnabled       = item.LogoutEnabled,
                    LogoutTime          = item.LogoutTime,
                    LanguageEditionCode = item.LanguageEditorPrevilages,
                };

                outputList.Add(newData);
            }

            return(outputList);
        }
Beispiel #2
0
        public LoggedUserData GetUserData()
        {
            _logger.Info($"Method for getin user data in case of successfull login fored.");

            if (_loginSuccessful)
            {
                try
                {
                    //read all data from DB
                    UserDefinition userData = _realm.All <UserDefinition>().Single(x => x.UserName == _userName);

                    //convert access level from number to enum
                    AccesLevelConverter converter   = new AccesLevelConverter();
                    AccessLevelEnum     accessLevel = converter.GetAccesLevelEnum(userData.AccessLevel);

                    //pass to caller only necessary data
                    return(new LoggedUserData()
                    {
                        Identity = userData.Identity,
                        UserName = userData.UserName,
                        AccessLevel = accessLevel.ToString(),
                        AccessLevelEnum = accessLevel,
                        LogoutEnabled = userData.LogoutEnabled,
                        LogoutTime = userData.LogoutTime,
                        LangEditPrevilages = userData.LanguageEditorPrevilages,
                    });
                }
                catch (Exception ex)
                {
                    _logger.Error($"Error while obtaining user data from DB: {ex.Message}.");
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }