virtual public async Task <NoticeRecord> Notify( string principalIdentifier, Mandate mandate, string purpose) { var information = await GetProcessingInformationFromSource(principalIdentifier, purpose); var documentRecord = await CreateNotificationDocument(information); if (documentRecord.WasSuccessful) { information.EmailParameters.Add("DocumentName", documentRecord.DocumentName); information.EmailParameters.Add("RequestKey", documentRecord.RequestKey); information.EmailAttachments.Add( new EmailAttachment { DisplayName = documentRecord.DocumentName, StorageName = documentRecord.DocumentName, } ); var result = await SendEmail(information); if (result.wasSuccess) { var noticeRecord = new NoticeRecord { Id = documentRecord.RequestKey, WasSuccessful = true, EmailStorageName = result.archiveFile, EmployeeIdentifier = principalIdentifier, NoticeStorageName = documentRecord.DocumentName, ProcessMessage = "Email and Document Sent", Mandate = mandate.ToString(), NoticeDate = DateTime.Now.Date }; noticeRecord.EmailNotices.Add( new EmailNotice { EmailStorageName = result.archiveFile, EmailAddress = information.EmailAddresses.FirstOrDefault() } ); await _storageService.SaveNoticeRecord(noticeRecord); } return(new NoticeRecord { WasSuccessful = true, EmailStorageName = null, EmployeeIdentifier = principalIdentifier, NoticeStorageName = documentRecord.DocumentName, ProcessMessage = "Notice was created but email failed" }); } return(new NoticeRecord { WasSuccessful = false, EmailStorageName = null, EmployeeIdentifier = principalIdentifier, NoticeStorageName = null, ProcessMessage = "Notice could not be created" }); }