Exemplo n.º 1
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
        }