public AppUserEntity GetAppUser(Guid userId)
        {
            AspnetAppUsers aspnetAppUserModel = checkNetDbContext.AspnetAppUsers.Find(userId);
            AppUserEntity  appUserEntity      = AppUserFactory.Create(aspnetAppUserModel.UserId, aspnetAppUserModel.FkAspnetAppCustomersCustNo
                                                                      , aspnetAppUserModel.CurrentUserProviderKey, aspnetAppUserModel.SelectedFileGroup, aspnetAppUserModel.SelectedFileGuid
                                                                      , aspnetAppUserModel.StatusCode, aspnetAppUserModel.EmailAddress, aspnetAppUserModel.FirstName, aspnetAppUserModel.LastName
                                                                      , aspnetAppUserModel.ReceiveStatusEmails, aspnetAppUserModel.ExportType, aspnetAppUserModel.LastUpdatedBy
                                                                      , aspnetAppUserModel.LastUpdateDate, aspnetAppUserModel.FileUploadMode);

            return(appUserEntity);
        }
        public async Task <string> CreateSerializedJtwTokenAsync(string userName)
        {
            var secretKey = _securityKeyFactory.CreateSecurityKey();
            var appUser   = _appUserFactory.Create(userName);

            var claims = await _userManager.GetClaimsAsync(appUser);

            var jwtHeader  = new JwtHeader(new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256));
            var jwtPayload = new JwtPayload(claims);
            var token      = new JwtSecurityToken(jwtHeader, jwtPayload);

            var result = new JwtSecurityTokenHandler().WriteToken(token);

            return(result);
        }
        public List <AppUserEntity> GetAppUsers()
        {
            List <AspnetAppUsers> AppUserEntitiesModels = checkNetDbContext.AspnetAppUsers.ToList();
            List <AppUserEntity>  AppUserEntities       = new List <AppUserEntity>();

            foreach (AspnetAppUsers aspnetAppUserModel in AppUserEntitiesModels)
            {
                AppUserEntity appUserEntity = AppUserFactory.Create(aspnetAppUserModel.UserId, aspnetAppUserModel.FkAspnetAppCustomersCustNo
                                                                    , aspnetAppUserModel.CurrentUserProviderKey, aspnetAppUserModel.SelectedFileGroup, aspnetAppUserModel.SelectedFileGuid
                                                                    , aspnetAppUserModel.StatusCode, aspnetAppUserModel.EmailAddress, aspnetAppUserModel.FirstName, aspnetAppUserModel.LastName
                                                                    , aspnetAppUserModel.ReceiveStatusEmails, aspnetAppUserModel.ExportType, aspnetAppUserModel.LastUpdatedBy
                                                                    , aspnetAppUserModel.LastUpdateDate, aspnetAppUserModel.FileUploadMode);
                AppUserEntities.Add(appUserEntity);
            }
            return(AppUserEntities);
        }
        public AppUserEntity GetAppUser(string username)
        {
            // find the id associated with username
            try
            {
                Guid userId = checkNetDbContext.AspnetUsers.Where(u => u.UserName == username.Trim()).FirstOrDefault().UserId;

                AspnetAppUsers aspnetAppUserModel = checkNetDbContext.AspnetAppUsers.Find(userId);
                // find the appuser with this id and construct entity
                AppUserEntity appUserEntity = AppUserFactory.Create(aspnetAppUserModel.UserId, aspnetAppUserModel.FkAspnetAppCustomersCustNo
                                                                    , aspnetAppUserModel.CurrentUserProviderKey, aspnetAppUserModel.SelectedFileGroup, aspnetAppUserModel.SelectedFileGuid
                                                                    , aspnetAppUserModel.StatusCode, aspnetAppUserModel.EmailAddress, aspnetAppUserModel.FirstName, aspnetAppUserModel.LastName
                                                                    , aspnetAppUserModel.ReceiveStatusEmails, aspnetAppUserModel.ExportType, aspnetAppUserModel.LastUpdatedBy
                                                                    , aspnetAppUserModel.LastUpdateDate, aspnetAppUserModel.FileUploadMode);

                return(appUserEntity);
            }catch (NullReferenceException e)
            {
                return(null);
            }
        }