public async Task ImportByLegacyIdsAsync_ImportsIdsFromList()
        {
            // Arrange
            var legacyIds = new List <string> {
                "1", "2", "3"
            };
            var notification1 = new Notification {
                NotificationId = 101, ETSID = "1"
            };
            var notification2 = new Notification {
                NotificationId = 102, ETSID = "2"
            };
            var notificationList = new List <IList <Notification> > {
                new[] { notification1 }, new[] { notification2 }
            };

            _notificationMapper.Setup(nm =>
                                      nm.GetNotificationsGroupedByPatient(_performContext, _runId, legacyIds))
            .Returns(Task.FromResult(notificationList.AsEnumerable()));

            // Act
            var importResults =
                await _notificationImportService.ImportByLegacyIdsAsync(_performContext, _runId, legacyIds);

            // Assert
            VerifyNotificationImportServicesAreCalled(notification1, Times.Once());
            VerifyNotificationImportServicesAreCalled(notification2, Times.Once());

            Assert.All(importResults, result => Assert.True(result.IsValid));
            Assert.Collection(importResults,
                              result => Assert.Contains(notification1.NotificationId, result.NtbsIds.Values),
                              result => Assert.Contains(notification2.NotificationId, result.NtbsIds.Values));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            RequestId = HttpContext.TraceIdentifier;
            var idsList = new List <string> {
                LegacyNotificationId
            };

            LegacyImportResult = (await _notificationImportService.ImportByLegacyIdsAsync(null, RequestId, idsList)).FirstOrDefault();

            if (LegacyImportResult != null && LegacyImportResult.IsValid)
            {
                var notificationId = LegacyImportResult.NtbsIds[LegacyNotificationId];
                return(RedirectToPage("/Notifications/Overview", new { NotificationId = notificationId }));
            }

            return(await GetPageAsync());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            var idsList = new List <string> {
                LegacyNotificationId
            };
            var migrationRun = await _notificationImportRepository.CreateLegacyImportMigrationRun(idsList);

            RunId = migrationRun.LegacyImportMigrationRunId;
            LegacyImportResult =
                (await _notificationImportService.ImportByLegacyIdsAsync(null, RunId, idsList)).FirstOrDefault();

            if (LegacyImportResult != null && LegacyImportResult.IsValid)
            {
                var notificationId = LegacyImportResult.NtbsIds[LegacyNotificationId];
                return(RedirectToPage("/Notifications/Overview", new { NotificationId = notificationId }));
            }

            return(await GetPageAsync());
        }