private static async Task LogServerResponseAsync(ServerResponseLog model) { using (var context = new ServerResponseDbContext()) { context.ServerResponseLogs.Add(model); await context.SaveChangesAsync(); } }
public async Task AddLogEntry(ServerResponse requestResponse) { var logEntry = new ServerResponseLog() { StartTime = requestResponse.StartTime, EndTime = requestResponse.EndTime, HttpStatusCode = requestResponse.HttpStatusCode, ResponseText = requestResponse.Response }; await context.AddAsync(logEntry); try { var resultCode = await context.SaveChangesAsync(); System.Console.WriteLine($"Logged entry result: {resultCode}"); } catch (DbUpdateException e) { System.Console.WriteLine($"Logged entry result failed: {e.InnerException.Message}"); } }