public static DalExceptionObject ToDalExceptionObject(this ExceptionObjectEntity exceptionObjectEntity) { if (exceptionObjectEntity == null) { return(null); } return(new DalExceptionObject() { Id = exceptionObjectEntity.Id, Message = exceptionObjectEntity.Message, Controller = exceptionObjectEntity.Controller, Action = exceptionObjectEntity.Action, Date = exceptionObjectEntity.Date, StackTrace = exceptionObjectEntity.StackTrace }); }
public void OnException(ExceptionContext filterContext) { ExceptionObjectEntity exceptionObject = new ExceptionObjectEntity() { Message = filterContext.Exception.Message, StackTrace = filterContext.Exception.StackTrace, Controller = filterContext.RouteData.Values["controller"].ToString(), Action = filterContext.RouteData.Values["action"].ToString(), Date = DateTime.Now }; ExceptionObjectService.Create(exceptionObject); filterContext.Result = filterContext.HttpContext.Response.StatusCode == 404 ? new ViewResult { ViewName = "~/Views/Error/NotFound.cshtml" } : new ViewResult { ViewName = "~/Views/Shared/Error.cshtml" }; filterContext.ExceptionHandled = true; }
public void Delete(ExceptionObjectEntity exceptionObject) { exceptionObjectRepository.Delete(exceptionObject.ToDalExceptionObject()); uow.Commit(); }