source: resTools_backend/backend/Email/EmailSender.cs

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
Line 
1using backend.Data;
2using backend.Entities;
3using SendGrid;
4using SendGrid.Helpers.Mail;
5
6namespace backend.Email;
7public interface IEmailSender
8{
9 Task SendEmailAsync(string subject, string body, string toEmail);
10}
11public class EmailSender : IEmailSender
12{
13
14 private readonly DataContext _context = null;
15 public EmailSender(DataContext context)
16 {
17 _context = context;
18 }
19
20 public async Task SendEmailAsync(string subject, string message, string toEmail)
21 {
22
23 _context.QueueItems.Add(new QueueItem()
24 {
25 Subject = subject,
26 Message = message,
27 Reciptient = toEmail,
28 CreatedAt = DateTime.UtcNow,
29 Retries = 0
30 });
31 await _context.SaveChangesAsync();
32 }
33}
Note: See TracBrowser for help on using the repository browser.