/// <summary> /// LogWebRequest Method for saving AppLogEntry details into DB /// </summary> /// <remarks>This LogWebRequest method object will invoke LogManagerDbContext.SaveChanges which will save details into DB</remarks> /// <param name="appLogEntry"></param> #region Log Request and Response public void LogWebRequest(AppLogEntry appLogEntry) { try { using (LogManagerDbContext db = new LogManagerDbContext()) { if (appLogEntry != null) { AppMessageLog msg = new AppMessageLog(); msg.AppMessageEntryId = appLogEntry.AppMessageEntryId; msg.ApplicationName = appLogEntry.ApplicationName; msg.User = appLogEntry.User; msg.Machine = appLogEntry.Machine; msg.RequestIpAddress = appLogEntry.RequestIpAddress; msg.RequestContentType = appLogEntry.RequestContentType; msg.RequestContentBody = appLogEntry.RequestContentBody; msg.RequestUri = appLogEntry.RequestUri; msg.RequestMethod = appLogEntry.RequestMethod; msg.RequestRouteTemplate = appLogEntry.RequestRouteTemplate; msg.RequestRouteData = appLogEntry.RequestRouteData; msg.RequestHeaders = appLogEntry.RequestHeaders; msg.RequestTimestamp = appLogEntry.RequestTimestamp; msg.ResponseContentType = appLogEntry.ResponseContentType; msg.ResponseContentBody = appLogEntry.ResponseContentBody; msg.ResponseStatusCode = appLogEntry.ResponseStatusCode; msg.ResponseHeaders = appLogEntry.ResponseHeaders; msg.ResponseTimestamp = appLogEntry.ResponseTimestamp; db.AppMessageLog.Add(msg); db.SaveChanges(); } } } catch (Exception ex) { throw ex; } finally { disposedValue = true; } }
public LogRepository(LogManagerDbContext dbContext) { this.dbContext = dbContext; }