private static void SaveExceptionToDatabase(Dictionary <int, string> toAddresses, Dictionary <int, string> ccAddresses, string message, string subject, Exception ex) { string commaSepratedToAddress = string.Empty; foreach (var item in toAddresses) { commaSepratedToAddress += item.Value + ","; } commaSepratedToAddress = commaSepratedToAddress.TrimEnd(','); string commaSepratedCCAddress = string.Empty; if (ccAddresses != null) { foreach (var item in ccAddresses) { commaSepratedCCAddress += item.Value + ","; } } commaSepratedCCAddress = commaSepratedCCAddress.TrimEnd(','); EmailExceptionModel objemailexception = new EmailExceptionModel() { ErrorInnerException = Convert.ToString(ex.InnerException), ErrorMessage = ex.Message, ErrorInnerExceptionMessage = ex.InnerException != null ? ex.InnerException.Message : "", MailMessage = message, MailSubject = subject, MailTo = commaSepratedToAddress, MailCC = commaSepratedCCAddress, }; //save to database when exception occurred _IDbErrorHandlingService.AddEmailException(objemailexception); //AppScope.ErrorHandlingServiceInstance.AddEmailException(objemailexception); }
public void AddEmailException(EmailExceptionModel objEmailExceptionModel) { var objEmailException = AutoMapper.Mapper.Map <EmailExceptionModel, EmailException>(objEmailExceptionModel); _dbErrorHandling.AddEmailException(objEmailException); }