public ExpendituresViewModel(List <Models.ProjectGrantAllocationExpenditure> projectGrantAllocationExpenditures, List <int> calendarYearsToPopulate, Models.Project project, List <ProjectExemptReportingYearSimple> projectExemptReportingYears) { ProjectExemptReportingYears = projectExemptReportingYears; Explanation = project.NoExpendituresToReportExplanation; ProjectGrantAllocationExpenditures = ProjectGrantAllocationExpenditureBulk.MakeFromList(projectGrantAllocationExpenditures, calendarYearsToPopulate); ShowValidationWarnings = true; }
public ExpendituresViewModel(ProjectUpdateBatch projectUpdateBatch, List <int> calendarYearsToPopulate, List <ProjectExemptReportingYearSimple> projectExemptReportingYears) { ProjectExemptReportingYears = projectExemptReportingYears; Explanation = projectUpdateBatch.NoExpendituresToReportExplanation; ProjectGrantAllocationExpenditures = ProjectGrantAllocationExpenditureBulk.MakeFromList(projectUpdateBatch.ProjectGrantAllocationExpenditureUpdates.ToList(), calendarYearsToPopulate); ShowValidationWarnings = true; Comments = projectUpdateBatch.ExpendituresComment; }
public PartialViewResult EditProjectGrantAllocationExpendituresForProject(ProjectPrimaryKey projectPrimaryKey) { var project = projectPrimaryKey.EntityObject; var projectGrantAllocationExpenditures = project.ProjectGrantAllocationExpenditures.ToList(); var calendarYearRange = projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(project); var projectExemptReportingYears = project.GetExpendituresExemptReportingYears().Select(x => new ProjectExemptReportingYearSimple(x)).ToList(); var currentExemptedYears = projectExemptReportingYears.Select(x => x.CalendarYear).ToList(); projectExemptReportingYears.AddRange(calendarYearRange.Where(x => !currentExemptedYears.Contains(x)).Select((x, index) => new ProjectExemptReportingYearSimple(-(index + 1), project.ProjectID, x))); var calendarYearRangeForExpenditures = projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(project); var projectGrantAllocationExpenditureBulks = ProjectGrantAllocationExpenditureBulk.MakeFromList(projectGrantAllocationExpenditures, calendarYearRangeForExpenditures); var viewModel = new EditProjectGrantAllocationExpendituresViewModel(project, projectGrantAllocationExpenditureBulks, projectExemptReportingYears); return(ViewEditProjectGrantAllocationExpenditures(project, viewModel, calendarYearRangeForExpenditures)); }
public void AllViewModelFieldsAreSetFromConstructorTest() { // Arrange var grantAllocation1 = TestFramework.TestGrantAllocation.Create(); var grantAllocation2 = TestFramework.TestGrantAllocation.Create(); var grantAllocation3 = TestFramework.TestGrantAllocation.Create(); var grantAllocation4 = TestFramework.TestGrantAllocation.Create(); var project = TestFramework.TestProject.Create(); TestFramework.TestProjectGrantAllocationExpenditure.Create(project, grantAllocation1); TestFramework.TestProjectGrantAllocationExpenditure.Create(project, grantAllocation2); TestFramework.TestProjectGrantAllocationExpenditure.Create(project, grantAllocation3); TestFramework.TestProjectGrantAllocationExpenditure.Create(project, grantAllocation4); var allGrantAllocations = new List <Models.GrantAllocation> { grantAllocation1, grantAllocation2, grantAllocation3, grantAllocation4 }; // Act var projectGrantAllocationExpenditures = project.ProjectGrantAllocationExpenditures.ToList(); var calendarYearRangeForExpenditures = projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(project); var viewModel = new EditProjectGrantAllocationExpendituresViewModel(null, ProjectGrantAllocationExpenditureBulk.MakeFromList(projectGrantAllocationExpenditures, calendarYearRangeForExpenditures), new List <ProjectExemptReportingYearSimple>()); // Assert Assert.That(viewModel.ProjectGrantAllocationExpenditures.Select(x => x.GrantAllocationID), Is.EquivalentTo(allGrantAllocations.Select(x => x.GrantAllocationID))); }