80 lines
1.8 KiB
C#
80 lines
1.8 KiB
C#
namespace MyOffice.Services.Notifications;
|
|
|
|
using MyOffice.Core;
|
|
using MyOffice.Data.Models.Notifications;
|
|
using MyOffice.Data.Models.Users;
|
|
using MyOffice.Data.Models.Verifications;
|
|
using MyOffice.Data.Repositories.Item;
|
|
using MyOffice.Services.Verifications;
|
|
|
|
public class EmailNotificationService
|
|
{
|
|
private readonly VerificationService _verificationService;
|
|
|
|
public EmailNotificationService(
|
|
VerificationService verificationService
|
|
)
|
|
{
|
|
_verificationService = verificationService;
|
|
}
|
|
|
|
public void PasswordResetEmail(User user)
|
|
{
|
|
var code = _verificationService.Add(
|
|
user,
|
|
user.Email,
|
|
VerificationCodeTemplateEnum.password_restore,
|
|
VerificationCodeTypeEnum.email
|
|
);
|
|
|
|
var subject = "";
|
|
var body = "";
|
|
}
|
|
}
|
|
|
|
public class TemplateSevice
|
|
{
|
|
private readonly IEmailTemplateRepository _emailTemplateRepository;
|
|
|
|
public TemplateSevice(
|
|
IEmailTemplateRepository emailTemplateRepository
|
|
)
|
|
{
|
|
_emailTemplateRepository = emailTemplateRepository;
|
|
}
|
|
|
|
public Exec<EmailTemplateFormated, GeneralExecStatus> GetTemplate(
|
|
EmailTemplateEnum template,
|
|
Dictionary<string, string> tokens
|
|
)
|
|
{
|
|
var result = new Exec<EmailTemplateFormated, GeneralExecStatus>(GeneralExecStatus.success);
|
|
|
|
var emailTemplate = _emailTemplateRepository.Get(template);
|
|
if (emailTemplate == null)
|
|
{
|
|
return result.Set(GeneralExecStatus.not_found);
|
|
}
|
|
|
|
result.Result = new EmailTemplateFormated
|
|
{
|
|
Subject = emailTemplate.Subject
|
|
Body = emailTemplate.Template,
|
|
};
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public class EmailTemplateFormated
|
|
{
|
|
public string Sender { get; set; }
|
|
public string SenderName { get; set; }
|
|
public string Subject { get; set; }
|
|
public string Body { get; set; }
|
|
}
|
|
|
|
public interface IEmailSender
|
|
{
|
|
//Exec<bool, GeneralExecStatus> Send(string from, string[] to, string subject, string body);
|
|
} |