DocSas/PropertyService.Domain/ModelView/Users/UserProvider.cs
/// <summary>
/// generate and send register email as an asynchronous operation.
/// </summary>
/// <param name="entity">The entity.</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
generate and send register email as an asynchronous operation.
generate and send register email as an asynchronous operation .
public async Task<DSCResponse> GenerateAndSendRegisterEmailAsync(User entity)
        {
            var response = new DSCResponse();
            var isSuccess = false;
            var verResponse = await _appCommon.GenarateVerificationCodeAsync(DSCMediaType.Email, DSCVerifyType.Register, entity.Id);
            if (verResponse.IsSuccess)
            {
                var verificationCode = verResponse.ResponseData as VerificationCode;
                var templates = await _notifyTemplateRepo.GetSingleAsync(x => x.TemplateType.Equals(NotifyTemplateKey.RegisterConfirmation, StringComparison.OrdinalIgnoreCase));
                if (templates != null)
                {
                    var appUrl = await _settingProvider.GetSetting(SettingKey.RegisterConfirmUrl);
                    var template = templates;
                    var emailBody = string.Format(template.TemplateHtml, entity.FirstName, string.Concat(appUrl, verificationCode?.Id));
                    emailBody = Utility.HtmlDecode(emailBody);
                    var dscEmail = new DSCEmail(new Tuple<string, string>(template.TemplateFromEmail, template.TemplateFromName),
                    new List<string>() { entity.Email }, template.TemplateSubject, emailBody);
                    await _emailProvider.SendEmailAsync(dscEmail);
                    isSuccess = true;
                }
            }
            if (!isSuccess)
            {
                response.ErrorMessage = new Dictionary<string, string>()
                {
                    {"Failed", "Failed" }
                };
            }
            response.ResponseData = isSuccess;
            return response;
        }
public async Task < DSCResponse > GenerateAndSendRegisterEmailAsync ( User entity ) { var response = new DSCResponse ( ) ; var isSuccess = false ; var verResponse = await _appCommon . GenarateVerificationCodeAsync ( DSCMediaType . Email , DSCVerifyType . Register , entity . Id ) ; if ( verResponse . IsSuccess ) { var verificationCode = verResponse . ResponseData as VerificationCode ; var templates = await _notifyTemplateRepo . GetSingleAsync ( x => x . TemplateType . Equals ( NotifyTemplateKey . RegisterConfirmation , StringComparison . OrdinalIgnoreCase ) ) ; if ( templates != null ) { var appUrl = await _settingProvider . GetSetting ( SettingKey . RegisterConfirmUrl ) ; var template = templates ; var emailBody = string . Format ( template . TemplateHtml , entity . FirstName , string . Concat ( appUrl , verificationCode ? . Id ) ) ; emailBody = Utility . HtmlDecode ( emailBody ) ; var dscEmail = new DSCEmail ( new Tuple < string , string > ( template . TemplateFromEmail , template . TemplateFromName ) , new List < string > ( ) { entity . Email } , template . TemplateSubject , emailBody ) ; await _emailProvider . SendEmailAsync ( dscEmail ) ; isSuccess = true ; } } if ( ! isSuccess ) { response . ErrorMessage = new Dictionary < string , string > ( ) { { " " , " " } } ; } response . ResponseData = isSuccess ; return response ; }
generate and send register email as an asynchronous operation.
generate and send register email as an asynchronous operation .
//Generate confirmation Notification
None
entity
User
None