From 6a9ce408d8ed641b6237026e833a286a2a6d3326 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 4 Apr 2017 19:48:14 -0400 Subject: [PATCH] more asynchrous stuff --- Project-Unite/App_Start/IdentityConfig.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Project-Unite/App_Start/IdentityConfig.cs b/Project-Unite/App_Start/IdentityConfig.cs index 66a80bb..a767b43 100644 --- a/Project-Unite/App_Start/IdentityConfig.cs +++ b/Project-Unite/App_Start/IdentityConfig.cs @@ -18,7 +18,7 @@ namespace Project_Unite { public class EmailService : IIdentityMessageService { - public Task SendAsync(IdentityMessage message) + public async Task SendAsync(IdentityMessage message) { try { @@ -41,7 +41,7 @@ public Task SendAsync(IdentityMessage message) var db = new ApplicationDbContext(); db.AuditLogs.Add(new AuditLog("system", AuditLogLevel.Admin, $"Email sending...

To: {sMsg.To}
Subject:
{sMsg.Subject}")); db.SaveChanges(); - smtp.SendCompleted += (o, a) => + smtp.SendCompleted += async (o, a) => { var alog = new AuditLog("system", AuditLogLevel.Admin, ""); if (a.Cancelled == true) @@ -52,7 +52,7 @@ public Task SendAsync(IdentityMessage message) alog.Description += $"Error:
{a.Error}
"; var ndb = new ApplicationDbContext(); ndb.AuditLogs.Add(alog); - ndb.SaveChanges(); + await ndb.SaveChangesAsync(); }; smtp.SendAsync(sMsg, null); } @@ -64,7 +64,7 @@ public Task SendAsync(IdentityMessage message) {ex}")); db.SaveChanges(); } - return Task.FromResult(0); + return; }