Пример #1
0
        public ProposalSectionsStatus(Models.Project project)
        {
            var basicsResults = new BasicsViewModel(project).GetValidationResults();

            IsBasicsSectionComplete = !basicsResults.Any();

            var customAttributeResults = new CustomAttributesViewModel(project).GetValidationResults();

            IsCustomAttributesSectionComplete = !customAttributeResults.Any();

            var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults();

            IsProjectLocationSimpleSectionComplete = !locationSimpleValidationResults.Any();

            IsProjectLocationDetailedSectionComplete = IsBasicsSectionComplete;

            var regionIDs = project.ProjectRegions
                            .Select(x => x.DNRUplandRegionID).ToList();
            var editProjectRegionsValidationResults = new EditProjectRegionsViewModel(regionIDs,
                                                                                      project.NoRegionsExplanation).GetValidationResults();

            IsRegionSectionComplete = !editProjectRegionsValidationResults.Any();

            var priorityLandscapeIDs = project.ProjectPriorityLandscapes
                                       .Select(x => x.PriorityLandscapeID).ToList();
            var editProjectPriorityLandscapesValidationResults = new EditProjectPriorityLandscapesViewModel(priorityLandscapeIDs,
                                                                                                            project.NoPriorityLandscapesExplanation).GetValidationResults();

            IsPriorityLandscapeSectionComplete = !editProjectPriorityLandscapesValidationResults.Any();

            var performanceMeasureValidationResults =
                new ExpectedPerformanceMeasureValuesViewModel(project).GetValidationResults();

            IsPerformanceMeasureSectionComplete = !performanceMeasureValidationResults.Any();

            var efValidationResults = new ExpectedFundingViewModel(project.ProjectGrantAllocationRequests.ToList(),
                                                                   project.EstimatedTotalCost,
                                                                   project.ProjectFundingSourceNotes,
                                                                   project.ProjectFundingSources.ToList())
                                      .GetValidationResults();

            IsExpectedFundingSectionComplete = !efValidationResults.Any();

            var proposalClassificationSimples   = ProjectCreateController.GetProjectClassificationSimples(project);
            var classificationValidationResults =
                new EditProposalClassificationsViewModel(proposalClassificationSimples).GetValidationResults();

            IsClassificationsComplete = !classificationValidationResults.Any();

            IsNotesSectionComplete = IsBasicsSectionComplete; //there is no validation required on Notes
        }
Пример #2
0
        /// <summary>
        /// Method to check whether each section in a proposal is complete
        ///
        /// </summary>
        /// <param name="project"></param>
        /// <param name="geospatialAreaTypes">Geospatial areas are defined per tenant, this is passed to check if the tenant has any and are complete</param>
        public ProposalSectionsStatus(ProjectFirmaModels.Models.Project project, List <GeospatialAreaType> geospatialAreaTypes, FirmaSession currentFirmaSession)
        {
            // Basics section
            var basicsResults = new BasicsViewModel(project).GetValidationResults();

            IsBasicsSectionComplete = !basicsResults.Any();

            // Custom Attributes section
            var customAttributesValidationResults = project.ValidateCustomAttributes(currentFirmaSession).GetWarningMessages();

            IsProjectCustomAttributesSectionComplete = !customAttributesValidationResults.Any();

            // Project Location simple section
            var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults();

            IsProjectLocationSimpleSectionComplete = !locationSimpleValidationResults.Any();

            // Project location detailed section
            IsProjectLocationDetailedSectionComplete = IsBasicsSectionComplete;

            // Geospatial Area section
            if (geospatialAreaTypes.Any())
            {
                var isGeospatialAreaSectionComplete = true;
                foreach (var geospatialAreaType in geospatialAreaTypes)
                {
                    var geospatialAreaIDs = project.ProjectGeospatialAreas.Where(x => x.GeospatialArea.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID).Select(x => x.GeospatialAreaID).ToList();
                    var editGeospatialAreaValidationResults = new EditProjectGeospatialAreasViewModel(geospatialAreaIDs, project.ProjectGeospatialAreaTypeNotes.SingleOrDefault(x => x.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID)?.Notes).GetValidationResults();
                    if (editGeospatialAreaValidationResults.Any())
                    {
                        isGeospatialAreaSectionComplete = false;
                        break;
                    }
                }

                IsGeospatialAreaSectionComplete = isGeospatialAreaSectionComplete;
            }
            else
            {
                IsGeospatialAreaSectionComplete = true;
            }

            // Performance Measure section
            IsPerformanceMeasureSectionComplete = IsBasicsSectionComplete;

            // Project FundingSource Budget and Cost Type section
            var calendarYearRange = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();
            var allProjectRelevantCostTypesAsSimples = project.GetAllProjectRelevantCostTypesAsSimples(ProjectRelevantCostTypeGroup.Budgets);
            var budgetValidationResults =
                new EditProjectFundingSourceBudgetByCostTypeViewModel(project, calendarYearRange,
                                                                      allProjectRelevantCostTypesAsSimples).GetValidationResults();

            IsExpectedFundingSectionComplete = !budgetValidationResults.Any();

            // Classifications section
            var proposalClassificationSimples   = ProjectCreateController.GetProjectClassificationSimples(project);
            var classificationValidationResults = new EditProposalClassificationsViewModel(proposalClassificationSimples, project).GetValidationResults();

            IsClassificationsComplete = !classificationValidationResults.Any();

            // Assessment section
            IsAssessmentComplete = ProjectCreateController.GetProjectAssessmentQuestionSimples(project).All(simple => simple.Answer.HasValue);

            // Notes section
            IsNotesSectionComplete = IsBasicsSectionComplete; //there is no validation required on Notes
        }