private void SaveExceptionToDatabase(Exception httpException) { var exceptionGuid = Guid.NewGuid(); IExceptionRepository exceptionRepository = DependencyResolver.Current.GetService(typeof(IExceptionRepository)) as IExceptionRepository; IExceptionEventRepository exceptionEventRepository = DependencyResolver.Current.GetService(typeof(IExceptionEventRepository)) as IExceptionEventRepository; IUserAuthentication authentication = DependencyResolver.Current.GetService(typeof(IUserAuthentication)) as IUserAuthentication; ISessionProvider sessionProvider = DependencyResolver.Current.GetService(typeof(ISessionProvider)) as ISessionProvider; var exceptions = this.GetAllExceptions(httpException) .ToList() .Select( exception => new ItanException { Message = exception.Message, Source = exception.Source, Stacktrace = exception.StackTrace, Typeof = exception.GetType().ToString(), ErrorId = exceptionGuid, UserId = authentication.CurrentUserIsAuthenticated() ? sessionProvider.GetCurrentUserId() : 0 }); var eventItanExceptions = exceptions.Select(e => new EventItanException() { ErrorId = exceptionGuid, ItanException = e }); //exceptionRepository.SaveToDatabase(exceptions); exceptionEventRepository.SaveToDatabase(eventItanExceptions); }