Beispiel #1
0
        public PartialViewResult EditProjectFundingSourceExpenditures(ProjectPrimaryKey projectPrimaryKey)
        {
            var project = projectPrimaryKey.EntityObject;
            var projectFundingSourceExpenditures = project.ProjectFundingSourceExpenditures.ToList();
            var projectFundingSourceBudgets      = project.ProjectFundingSourceBudgets.ToList();



            var calendarYearRangeForExpenditures     = projectFundingSourceExpenditures.CalculateCalendarYearRangeForExpenditures(project);
            var projectFundingSourceExpenditureBulks = ProjectFundingSourceExpenditureBulk.MakeFromList(projectFundingSourceExpenditures, calendarYearRangeForExpenditures);



            if (!projectFundingSourceExpenditures.Any() && projectFundingSourceBudgets.Any())
            {
                calendarYearRangeForExpenditures = project.GetProjectUpdatePlanningDesignStartToCompletionYearRange();
                if (calendarYearRangeForExpenditures.Any())
                {
                    projectFundingSourceExpenditureBulks = ProjectFundingSourceExpenditureBulk.MakeFromList(projectFundingSourceBudgets, calendarYearRangeForExpenditures);
                }
            }

            var viewModel = new EditProjectFundingSourceExpendituresViewModel(project, projectFundingSourceExpenditureBulks);

            return(ViewEditProjectFundingSourceExpenditures(project, viewModel));
        }
Beispiel #2
0
        public void AllViewModelFieldsAreSetFromConstructorTest()
        {
            // Arrange
            var fundingSource1 = TestFramework.TestFundingSource.Create();
            var fundingSource2 = TestFramework.TestFundingSource.Create();
            var fundingSource3 = TestFramework.TestFundingSource.Create();
            var fundingSource4 = TestFramework.TestFundingSource.Create();

            var project = TestFramework.TestProject.Create();

            TestFramework.TestProjectFundingSourceExpenditure.Create(project, fundingSource1);
            TestFramework.TestProjectFundingSourceExpenditure.Create(project, fundingSource2);
            TestFramework.TestProjectFundingSourceExpenditure.Create(project, fundingSource3);
            TestFramework.TestProjectFundingSourceExpenditure.Create(project, fundingSource4);

            var allFundingSources = new List <ProjectFirmaModels.Models.FundingSource> {
                fundingSource1, fundingSource2, fundingSource3, fundingSource4
            };

            // Act
            var projectFundingSourceExpenditures = project.ProjectFundingSourceExpenditures.ToList();
            var calendarYearRangeForExpenditures = projectFundingSourceExpenditures.CalculateCalendarYearRangeForExpenditures(project);
            var viewModel = new EditProjectFundingSourceExpendituresViewModel(project, ProjectFundingSourceExpenditureBulk.MakeFromList(projectFundingSourceExpenditures, calendarYearRangeForExpenditures));

            // Assert
            Assert.That(viewModel.ProjectFundingSourceExpenditures.Select(x => x.FundingSourceID), Is.EquivalentTo(allFundingSources.Select(x => x.FundingSourceID)));
        }