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()); }
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 }
private static void SaveProjectDetailedLocations(ProjectLocationDetailViewModel viewModel, Project project, out bool hadToMakeValid, out bool atLeastOneCouldNotBeCorrected) { foreach (var projectLocation in project.GetProjectLocationDetailedAsProjectLocations(true).ToList()) { projectLocation.DeleteFull(HttpRequestStorage.DatabaseEntities); } hadToMakeValid = false; atLeastOneCouldNotBeCorrected = false; if (viewModel.WktAndAnnotations != null) { var dbGeomsToAdd = ProjectCreateController.MakeValidDbGeometriesFromWellKnownTextAndAnnotations( viewModel.WktAndAnnotations, out hadToMakeValid, out atLeastOneCouldNotBeCorrected); foreach (var dbGeomTuple in dbGeomsToAdd) { project.ProjectLocations.Add(new ProjectLocation(project, dbGeomTuple.Item1, dbGeomTuple.Item2)); } } }
/// <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 }
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}"); } }