LogEventInterop ToInterop(LogEvent le) { LogEventInterop lei = new LogEventInterop(); lei.Message = le.Message; lei.InnerException = le.InnerException; return(lei); }
LogEvent FromInterop(LogEventInterop lei) { LogEvent le = new LogEvent(); le.Message = lei.Message; le.InnerException = lei.InnerException; return(le); }
// GET: Error public async Task <ActionResult> Index() { Exception e = Server.GetLastError(); LogEventInterop lei = new LogEventInterop(); lei.Title = "Web error"; lei.Message = e.Message; lei.InnerException = e.InnerException.Message; lei.StackTrace = e.StackTrace; await WebApi(WebApiMethod.Post, "api/LogEvent", lei); return(View("Error")); }
public async Task <IHttpActionResult> PostLogEvent(LogEventInterop lei) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } LogEvent le = FromInterop(lei); db.LogEvents.Add(le); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = le.Id }, lei)); }