Esempio n. 1
0
        public async Task SelectTestNotifierByName()
        {
            var expected = new NoticeRecord
            {
                WasSuccessful  = true,
                ProcessMessage = "The correct processor was selected"
            };

            var notExpected = new NoticeRecord
            {
                WasSuccessful  = true,
                ProcessMessage = "The wrong processor was selected"
            };

            var testNotifier = new Mock <ITestNotifier>();
            var dcNotifier   = new Mock <IDCWageNotifier>();

            testNotifier.Setup(x => x.Notify(It.IsAny <string>(), Mandate.TestNotifications, "Test")).ReturnsAsync(expected);
            dcNotifier.Setup(x => x.Notify(It.IsAny <string>(), Mandate.TestNotifications, "Test")).ReturnsAsync(notExpected);

            var cut    = new NoticeProviderSelector(dcNotifier.Object, testNotifier.Object);
            var actual = await cut.Notify("recipientId", Mandate.TestNotifications, "Test");

            Assert.Equal(expected.ProcessMessage, actual.ProcessMessage, true, true);
        }
        public async Task <bool> SaveRecord(NoticeRecord record)
        {
            var response = await _dbContext.Client.CreateDocumentAsync(
                UriFactory.CreateDocumentCollectionUri(_dbContext.DatabaseId, _dbContext.CollectionId), record);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        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"
            });
        }
Esempio n. 4
0
 public async Task SaveNoticeRecord(NoticeRecord noticeRecord)
 {
     await _noticeRecordRepository.SaveRecord(noticeRecord);
 }
Esempio n. 5
0
 public object Any(NoticeRecord request)
 {
     return(new NoticeRecordResponse {
         Result = "some result"
     });
 }