private void AddApplicationsToViewModel(ClosedApplicationsViewModel viewModel, List <ClosedApplicationSummary> applications) { foreach (var application in applications) { var applicationVm = CreateApplicationViewModel(application); viewModel.AddApplication(applicationVm); } }
public async Task <ClosedApplicationsViewModel> GetClosedApplicationsViewModel(string userId) { var applicationSummary = await _applicationApiClient.GetApplicationCounts(userId); var applications = await _applicationApiClient.GetClosedApplications(userId); var viewModel = new ClosedApplicationsViewModel(userId, applicationSummary.NewApplications, applicationSummary.InProgressApplications, applicationSummary.ModerationApplications, applicationSummary.ClarificationApplications, applicationSummary.ClosedApplications); AddApplicationsToViewModel(viewModel, applications); return(viewModel); }
public async Task When_getting_closed_applications_the_applications_are_returned() { var userId = _controller.User.UserId(); var expectedViewModel = new ClosedApplicationsViewModel(userId, 1, 2, 3, 4, 5); _outcomeOrchestrator.Setup(x => x.GetClosedApplicationsViewModel(userId)).ReturnsAsync(expectedViewModel); var result = await _controller.ClosedApplications(); Assert.AreSame(expectedViewModel, result.Model); }