public async Task LogAsync(HttpRequest request, string hash = null) { RequestLogEntry requestEntity = GetRequestEntity(request, hash); using (var context = new RequestLoggingContext()) { context.Requests.Add(requestEntity); await context.SaveChangesAsync(); } }
private static RequestLogEntry GetRequestEntity(HttpRequest request, string hash) { return new RequestLogEntry() { Created = DateTime.UtcNow, Hash = hash, Method = request.Method, Url = request.RequestUri.ToString() }; }