34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using OFBButte.Application.Database;
|
|
using OFBButte.Application.Email;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace OFBButte.Application.Missionary
|
|
{
|
|
public class SendMissionaryFormEmail
|
|
{
|
|
private readonly IOFBContext context;
|
|
private readonly IEmailSender emailSender;
|
|
public SendMissionaryFormEmail(IOFBContext context, IEmailSender emailSender)
|
|
{
|
|
this.context = context;
|
|
this.emailSender = emailSender;
|
|
}
|
|
|
|
public async Task Handle(int missionaryFormId, string emailAddress)
|
|
{
|
|
var form = context.MissionarySupportForms.FirstOrDefault(m => m.Id == missionaryFormId);
|
|
if (form == null)
|
|
throw new Exception($"Form with id {missionaryFormId} not found");
|
|
|
|
var email = new Email.MissionarySupportFormEmail(form.ToDictionary());
|
|
email.To = emailAddress;
|
|
|
|
await emailSender.Send(email);
|
|
}
|
|
}
|
|
}
|