using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; namespace MEU.API.Services.Emails.Templates { public class EmailXMaxUnlockCode : EmailContent { string _UnlockCode; string _Username; public EmailXMaxUnlockCode(string UnlockCode, string Username, string RecieverUser) { this.EmailTemplatePath += "/EmailXMaxUnlockCode.html"; this._Username = Username; this._UnlockCode = UnlockCode; this.Reciever = RecieverUser; this.Subject = "Mã mở khóa app Xmax Key"; } public override string GetContent() { string fullBody = "Chào {{ten}}, Đây là mã mở khóa {{UNLOCK_CODE}}"; if (File.Exists(this.EmailTemplatePath)) { fullBody = File.ReadAllText(this.EmailTemplatePath); } else { fullBody += "\r\nCannot find template email at path:" + this.EmailTemplatePath; } // fullBody = fullBody.Replace("{{ten}}", this._Username); fullBody = fullBody.Replace("{{UNLOCK_CODE}}", this._UnlockCode); 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())); } } }