Last change
on this file was 13f1472, checked in by Danilo <danilo.najkov@…>, 2 years ago |
vip functionallity + menu fields + alergens filtering + google/fb login + email queueing
|
-
Property mode
set to
100644
|
File size:
773 bytes
|
Rev | Line | |
---|
[13f1472] | 1 | using backend.Data;
|
---|
| 2 | using backend.Entities;
|
---|
| 3 | using SendGrid;
|
---|
[a26f6a1] | 4 | using SendGrid.Helpers.Mail;
|
---|
| 5 |
|
---|
| 6 | namespace backend.Email;
|
---|
| 7 | public interface IEmailSender
|
---|
| 8 | {
|
---|
| 9 | Task SendEmailAsync(string subject, string body, string toEmail);
|
---|
| 10 | }
|
---|
| 11 | public class EmailSender : IEmailSender
|
---|
| 12 | {
|
---|
[13f1472] | 13 |
|
---|
| 14 | private readonly DataContext _context = null;
|
---|
| 15 | public EmailSender(DataContext context)
|
---|
| 16 | {
|
---|
| 17 | _context = context;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
[a26f6a1] | 20 | public async Task SendEmailAsync(string subject, string message, string toEmail)
|
---|
| 21 | {
|
---|
[13f1472] | 22 |
|
---|
| 23 | _context.QueueItems.Add(new QueueItem()
|
---|
[a26f6a1] | 24 | {
|
---|
| 25 | Subject = subject,
|
---|
[13f1472] | 26 | Message = message,
|
---|
| 27 | Reciptient = toEmail,
|
---|
| 28 | CreatedAt = DateTime.UtcNow,
|
---|
| 29 | Retries = 0
|
---|
| 30 | });
|
---|
| 31 | await _context.SaveChangesAsync();
|
---|
[a26f6a1] | 32 | }
|
---|
| 33 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.