using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace MEU.API.Services.Emails.Templates
{
    public class EmailSetupNewPassword: EmailContent
    {
        protected string _Link = "";
        protected string _Username = "";

        public EmailSetupNewPassword(string EmailSubject, string Link, string Username, string RecieverUser)
        {
            this.EmailTemplatePath += "/EmailSetupNewPassword.html";
            _Link = Link;
            _Username = Username;
            this.Reciever = RecieverUser;
            this.Subject = EmailSubject;
        }

        public override string GetContent()
        {
            string fullBody =  File.ReadAllText(this.EmailTemplatePath);
            fullBody = fullBody.Replace("{{link}}", this._Link);
            fullBody = fullBody.Replace("{{username}}", this.Reciever);
            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()));
        }
    }
}
