using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; namespace MEU.API.Services.Emails.Templates { public class EmailOTPCheckInTool:EmailContent { protected string _OTPCode = ""; protected string _Username = ""; public EmailOTPCheckInTool(string EmailSubject, string OTPCode, string Username, string RecieverUser) { this.EmailTemplatePath += "/EmailOTPCheckInTool.html"; _OTPCode = OTPCode; _Username = Username; this.Reciever = RecieverUser; this.Subject = EmailSubject; } public override string GetContent() { string fullBody = "Đây là mã OTP cho user {{username}}: {{otplogin}} "; if (File.Exists(this.EmailTemplatePath)) { fullBody = File.ReadAllText(this.EmailTemplatePath); } else { fullBody += "\r\nCannot find template email at path:" + this.EmailTemplatePath; } // fullBody = fullBody.Replace("{{otplogin}}", this._OTPCode); fullBody = fullBody.Replace("{{username}}", this._Username); return fullBody; } public override bool Send() { this.SendEmail(this.Reciever, this.Subject, this.GetContent()); return true; } public override async Task SendAsync() { await Task.Run(() => this.SendEmailAsync(this.Reciever, this.Subject, this.GetContent())); } } }