public UserInfo GetUserInfo(UserInfoKey key)
 {
     UserInfo userInfo = null;
     string cacheKey = key == null ? "UserInfoKey_null" : key.GetCacheKey();
     if (key != null && !TryGetCacheData(cacheKey, out userInfo))
     {
         userInfo = GetUserInfoManager().GetUserInfo(key);
         SetCacheData(_cacheName, cacheKey, userInfo);
     }
     return userInfo;
 }
Exemple #2
0
        /// <summary>
        /// Delete data in database
        /// </summary>
        /// <param name="key">Primary Key</param>
        public void Delete(UserInfoKey key)
        {
            if (key == null || string.IsNullOrWhiteSpace(key.UserId))
                return;

            var row = _dbContext.UserInfo.Where(m => m.UserId == key.UserId).FirstOrDefault();
            if (row != null)
            {
                _dbContext.UserInfo.Remove(row);
                _dbContext.SaveChanges();
            }
        }
Exemple #3
0
        public async Task<IActionResult> ConfirmUserEmail(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                var appUser = await _identityUserManager.FindByIdAsync(id);
                if (appUser != null && !appUser.EmailConfirmed)
                {
                    appUser.EmailConfirmed = true;
                    await _identityUserManager.UpdateAsync(appUser);

                    //Add user role
                    var userKey = new UserKey() { Id = id };
                    var user = _usersService.GetUser(userKey);
                    if (user != null)
                    {
                        //Verify role exist
                        var roleKey = new RoleKey();
                        roleKey.Id = "1"; //User
                        var role = _rolesService.GetRole(roleKey);
                        if (role != null)
                        {
                            user.Role = role;
                            user = _usersService.UpdateUser(user);
                        }
                    }

                    //Add empty user profil (for correct connect error on mobile application)
                    var userInfoKey = new UserInfoKey() { UserId = id };
                    var userInfo = _userInfosService.GetUserInfo(userInfoKey);
                    if (userInfo == null)
                    {
                        userInfo = new UserInfo()
                        {
                            UserId = id,
                            Unit = TUnitType.Metric
                        };
                        _userInfosService.UpdateUserInfo(userInfo);
                    }

                    try
                    {
                        await _emailSender.SendEmailAsync(appUser.Email, "Account validated",
                            "Your account validated by admin");
                    }
                    catch(Exception except)
                    {
                        _logger.LogError(0, except, "can't send email");
                    }
                }
            }
            return RedirectToAction("Index");
        }
 internal UserInfo GetUserInfo(UserInfoKey key)
 {
     return _userInfoModule.Get(key);
 }
 internal void DeleteUserInfo(UserInfoKey key)
 {
     _userInfoModule.Delete(key);
 }
Exemple #6
0
        /// <summary>
        /// Get data in database
        /// </summary>
        /// <param name="key">Primary Key</param>
        /// <returns>read data</returns>
        public UserInfo Get(UserInfoKey key)
        {
            if (key == null || string.IsNullOrWhiteSpace(key.UserId))
                return null;

            var row = _dbContext.UserInfo.Where(m => m.UserId == key.UserId).FirstOrDefault();
            if (row != null)
            {
                return UserInfoTransformer.ToBean(row);
            }
            return null;
        }