Exemplo n.º 1
0
        public override bool IsComplete(Project project)
        {
            if (project == null)
            {
                return(false);
            }

            var projectClassificationSimples = ProjectCreateController.GetProjectClassificationSimples(project);

            var classificationValidationResults = new EditProposalClassificationsViewModel(projectClassificationSimples).GetValidationResults();

            return(!classificationValidationResults.Any());
        }
Exemplo n.º 2
0
        public static bool IsComplete(this ProjectCreateSection projectCreateSection, Project project)
        {
            if (project == null)
            {
                return(false);
            }

            var currentFirmaSession = HttpRequestStorage.FirmaSession;

            switch (projectCreateSection.ToEnum)
            {
            case ProjectCreateSectionEnum.Basics:
                return(!new BasicsViewModel(project).GetValidationResults().Any());

            case ProjectCreateSectionEnum.CustomAttributes:
                return(project.AreProjectCustomAttributesValid(currentFirmaSession));

            case ProjectCreateSectionEnum.LocationSimple:
                var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults();
                return(!locationSimpleValidationResults.Any());

            case ProjectCreateSectionEnum.Organizations:
                return(!new OrganizationsViewModel(project, currentFirmaSession).GetValidationResults().ToList().Any());

            case ProjectCreateSectionEnum.Contacts:
                return(!new ContactsViewModel(project, currentFirmaSession).GetValidationResults().ToList().Any());

            case ProjectCreateSectionEnum.LocationDetailed:
                return(true);

            case ProjectCreateSectionEnum.ExpectedAccomplishments:
                return(true);

            case ProjectCreateSectionEnum.ReportedAccomplishments:
                if (!MultiTenantHelpers.TrackAccomplishments())
                {
                    return(true);
                }
                var pmValidationResults = new PerformanceMeasuresViewModel(
                    project.PerformanceMeasureActuals.Select(x => new PerformanceMeasureActualSimple(x)).ToList(),
                    project.PerformanceMeasureActualYearsExemptionExplanation,
                    project.GetPerformanceMeasuresExemptReportingYears().Select(x => new ProjectExemptReportingYearSimple(x)).ToList(), project)
                {
                    ProjectID = project.ProjectID
                }.GetValidationResults();
                return(!pmValidationResults.Any());

            case ProjectCreateSectionEnum.Budget:
                // todo: more complicated than that.
                return(ProjectCreateSection.Basics.IsComplete(project));

            //case ProjectCreateSectionEnum.ReportedExpenditures:
            //    if (MultiTenantHelpers.GetTenantAttributeFromCache().BudgetType == BudgetType.AnnualBudgetByCostType)
            //    {
            //        var expectedYears =
            //            project.CalculateCalendarYearRangeForExpendituresWithoutAccountingForExistingYears();
            //        var missingYears = expectedYears.GetMissingYears(project.ProjectFundingSourceExpenditures.Select(x => x.CalendarYear)).ToList();

            //        // for expenditures by cost type, we are just validating that either they have any expenditures for the required year range or they have no expenditures but have an explanation
            //        return (project.ProjectFundingSourceExpenditures.Any() && !missingYears.Any() &&
            //                string.IsNullOrWhiteSpace(project.ExpendituresNote)) ||
            //               (!project.ProjectFundingSourceExpenditures.Any() &&
            //                !string.IsNullOrWhiteSpace(project.ExpendituresNote));
            //    }
            //    else
            //    {
            //        var projectFundingSourceExpenditures = project.ProjectFundingSourceExpenditures.ToList();
            //        var calendarYearRangeForExpenditures = projectFundingSourceExpenditures.CalculateCalendarYearRangeForExpenditures(project);
            //        var projectFundingSourceExpenditureBulks = ProjectFundingSourceExpenditureBulk.MakeFromList(projectFundingSourceExpenditures, calendarYearRangeForExpenditures);
            //        var validationResults = new ExpendituresViewModel(projectFundingSourceExpenditureBulks,
            //                    project)
            //                {ProjectID = project.ProjectID}
            //            .GetValidationResults();
            //        return !validationResults.Any();
            //    }

            case ProjectCreateSectionEnum.Classifications:
                var projectClassificationSimples    = ProjectCreateController.GetProjectClassificationSimples(project);
                var classificationValidationResults = new EditProposalClassificationsViewModel(projectClassificationSimples, project).GetValidationResults();
                return(!classificationValidationResults.Any());

            case ProjectCreateSectionEnum.Assessment:
                return(!new EditAssessmentViewModel(project.ProjectAssessmentQuestions.Select(x => new ProjectAssessmentQuestionSimple(x)).ToList()).GetValidationResults().Any());

            case ProjectCreateSectionEnum.Photos:
                return(ProjectCreateSection.Basics.IsComplete(project));

            case ProjectCreateSectionEnum.AttachmentsAndNotes:
                return(ProjectCreateSection.Basics.IsComplete(project));

            case ProjectCreateSectionEnum.BulkSetSpatialInformation:
                return(ProjectCreateSection.Basics.IsComplete(project));

            case ProjectCreateSectionEnum.PartnerFinder:
                return(true);

            case ProjectCreateSectionEnum.ExternalLinks:
                return(ProjectCreateSection.Basics.IsComplete(project));

            default:
                throw new ArgumentOutOfRangeException($"IsComplete(): Unhandled ProjectCreateSection Enum: {projectCreateSection.ToEnum}");
            }
        }