Ignore:
Timestamp:
09/18/22 18:09:53 (2 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Parents:
49b0bbd
Message:

vip functionallity + menu fields + alergens filtering + google/fb login + email queueing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • resTools_backend/backend/Email/EmailSender.cs

    r49b0bbd r13f1472  
    1 using SendGrid;
     1using backend.Data;
     2using backend.Entities;
     3using SendGrid;
    24using SendGrid.Helpers.Mail;
    35
     
    911public class EmailSender : IEmailSender
    1012{
     13
     14    private readonly DataContext _context = null;
     15    public EmailSender(DataContext context)
     16    {
     17        _context = context;
     18    }
     19
    1120    public async Task SendEmailAsync(string subject, string message, string toEmail)
    1221    {
    13         var client = new SendGridClient("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");
    14         var msg = new SendGridMessage()
     22
     23        _context.QueueItems.Add(new QueueItem()
    1524        {
    16             From = new EmailAddress("danilo.najkov@students.finki.ukim.mk", "Danilo"),
    1725            Subject = subject,
    18             PlainTextContent = message,
    19             HtmlContent = message
    20         };
    21         msg.AddTo(new EmailAddress(toEmail));
    22         msg.SetClickTracking(false, false);
    23         var response = await client.SendEmailAsync(msg);
     26            Message = message,
     27            Reciptient = toEmail,
     28            CreatedAt = DateTime.UtcNow,
     29            Retries = 0
     30        });
     31        await _context.SaveChangesAsync();
    2432    }
    2533}
Note: See TracChangeset for help on using the changeset viewer.