public async Task <IdentityResult> PrepareSendVerifyEmailMessage(User user)
        {
            var currentUser = await FindByIdAsync(user.Id);

            var now         = DateTimeOffset.UtcNow;
            var expire      = now.AddMinutes(3);
            var hashedEmail = passwordHasher.HashPassword(currentUser, currentUser.Email);
            var code        = valueGenerator.GetRandomString(13);
            var hashedCode  = passwordHasher.HashPassword(currentUser, code);

            var verifyEmail = new UserVerifyCode
            {
                Email     = hashedEmail,
                Code      = hashedCode,
                CreatedAt = DateTimeOffset.UtcNow,
                UserId    = currentUser.Id,
                Expire    = expire,
            };

            blogDbContext.UserVerifyCodes.Add(verifyEmail);

            try
            {
                await blogDbContext.SaveChangesAsync();

                await SendVerifyEmailMessage(currentUser, verifyEmail);

                return(IdentityResult.Success);
            }
            catch (Exception ex)
            {
                return(ProcessException(ex));
            }
        }
        public async Task <IdentityResult> SendVerifyEmailMessage(User user, UserVerifyCode userVerifyCode)
        {
            var to = new List <EmailAddressInfo> {
                new EmailAddressInfo {
                    Address     = user.Email,
                    DisplayName = user.DisplayName,
                }
            };

            var url = $"{GetBaseUrl()}/verifyemail?email={userVerifyCode.Email}&code={userVerifyCode.Code}";

            var subject = $"Verify your email address ";
            var body    = $@"<h1>Verify Email Address</h1>
<p>Please navigate below link.</p>
<a href=""{ url }"">Verify email</a>

<p>Please copy below url and paste address window on your web browser when may be unavailable navigating a link.</p>
<pre><code>${ url }</code></pre>

     <p> These link are valid until {String.Format("{0:yyyy-MM-dd HH:mm:ss} UTC", userVerifyCode.Expire)}</p>
 <hr />
 <p> Please do not reply this email.</p> ";

            var result = await mailSender.SendAsync(to, null, null, subject, body, true);

            if (result.Success)
            {
                return(IdentityResult.Success);
            }
            else
            {
                logger.LogDebug($"SEND MAIL FAILED. {result.Description}");

                return(IdentityResult.Failed(new IdentityError
                {
                    Code = result.ErrorCode,
                    Description = result.Description
                }));
            }
        }