Beispiel #1
0
        public static List <ProjectSectionSimple> GetProjectUpdateSections(this ProjectWorkflowSectionGrouping projectWorkflowSectionGrouping,
                                                                           FirmaSession currentFirmaSession,
                                                                           ProjectUpdateBatch projectUpdateBatch,
                                                                           ProjectUpdateStatus projectUpdateStatus,
                                                                           bool ignoreStatus,
                                                                           bool hasEditableCustomAttributes)
        {
            switch (projectWorkflowSectionGrouping.ToEnum)
            {
            case ProjectWorkflowSectionGroupingEnum.Overview:
                // remove the custom attributes section from the overview section to begin with
                var projectUpdateSectionForCustomAttributes = projectWorkflowSectionGrouping.ProjectUpdateSections.Except(new List <ProjectUpdateSection> {
                    ProjectUpdateSection.CustomAttributes
                }).ToList();
                // If there are custom attribute types for this tenant, we can add the section back
                if (hasEditableCustomAttributes)
                {
                    projectUpdateSectionForCustomAttributes.Add(ProjectUpdateSection.CustomAttributes);
                }
                return(GetProjectUpdateSectionsImpl(projectUpdateBatch, projectUpdateSectionForCustomAttributes, projectUpdateStatus, ignoreStatus));

            case ProjectWorkflowSectionGroupingEnum.SpatialInformation:
                var geospatialAreaTypes = HttpRequestStorage.DatabaseEntities.GeospatialAreaTypes;
                var updateSections      = projectWorkflowSectionGrouping.ProjectUpdateSections.Except(new List <ProjectUpdateSection> {
                    ProjectUpdateSection.BulkSetSpatialInformation
                }).ToList();
                if (geospatialAreaTypes.Count() > 1)
                {
                    updateSections.Add(ProjectUpdateSection.BulkSetSpatialInformation);
                }
                var projectUpdateSections = GetProjectUpdateSectionsImpl(projectUpdateBatch, updateSections, projectUpdateStatus, ignoreStatus);
                //Bulk Set is the only section setup for spatial areas in the DB. so we always want to start with that sort order
                int maxSortOrder = ProjectUpdateSection.BulkSetSpatialInformation.SortOrder;
                projectUpdateSections.AddRange(geospatialAreaTypes
                                               .OrderBy(x => x.GeospatialAreaTypeName).ToList().Select((geospatialAreaType, index) =>
                                                                                                       new ProjectSectionSimple(geospatialAreaType.GeospatialAreaTypeNamePluralized, maxSortOrder + index + 1,
                                                                                                                                !projectUpdateBatch.IsNew(), projectWorkflowSectionGrouping,
                                                                                                                                projectUpdateBatch.IsNew() ? null :
                                                                                                                                SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(y =>
                                                                                                                                                                                             y.GeospatialArea(projectUpdateBatch.Project, geospatialAreaType)),
                                                                                                                                projectUpdateStatus != null && projectUpdateBatch.IsProjectGeospatialAreaValid(geospatialAreaType),
                                                                                                                                projectUpdateStatus != null && IsGeospatialAreaUpdated(projectUpdateBatch, geospatialAreaType)
                                                                                                                                )));
                return(projectUpdateSections);

            case ProjectWorkflowSectionGroupingEnum.Accomplishments:
                var projectUpdateSectionsForPerformanceMeasures = projectWorkflowSectionGrouping.ProjectUpdateSections.Except(new List <ProjectUpdateSection> {
                    ProjectUpdateSection.ReportedAccomplishments
                }).ToList();
                if (projectUpdateBatch.AreAccomplishmentsRelevant())
                {
                    projectUpdateSectionsForPerformanceMeasures.Add(ProjectUpdateSection.ReportedAccomplishments);
                }
                return(GetProjectUpdateSectionsImpl(projectUpdateBatch, projectUpdateSectionsForPerformanceMeasures, projectUpdateStatus, ignoreStatus));

            case ProjectWorkflowSectionGroupingEnum.Financials:
                var projectUpdateSectionsForExpenditures = projectWorkflowSectionGrouping.ProjectUpdateSections.Except(new List <ProjectUpdateSection> {
                    ProjectUpdateSection.Budget
                }).ToList();
                if (projectUpdateBatch.Project.IsExpectedFundingRelevant())
                {
                    projectUpdateSectionsForExpenditures.Add(ProjectUpdateSection.Budget);
                }
                return(GetProjectUpdateSectionsImpl(projectUpdateBatch, projectUpdateSectionsForExpenditures, projectUpdateStatus, ignoreStatus));

            case ProjectWorkflowSectionGroupingEnum.AdditionalData:
                var additionalDataProjectUpdateSections = projectWorkflowSectionGrouping.ProjectUpdateSections.ToList();

                var sections = GetProjectUpdateSectionsImpl(projectUpdateBatch, additionalDataProjectUpdateSections, projectUpdateStatus, ignoreStatus);
                // Remove Technical Assistance Requests for all tenants except Idaho
                if (!MultiTenantHelpers.UsesTechnicalAssistanceParameters())
                {
                    sections = sections.Where(x => x.SectionDisplayName != ProjectUpdateSection.TechnicalAssistanceRequests.ProjectUpdateSectionDisplayName).ToList();
                }
                return(sections);

            // Partner Finder
            // Whole section is conditional
            case ProjectWorkflowSectionGroupingEnum.Partners:
                bool shouldShowPartnerFinder = new MatchMakerViewPotentialPartnersFeature().HasPermissionForProjectByFirmaSession(currentFirmaSession, projectUpdateBatch.Project);
                if (!shouldShowPartnerFinder)
                {
                    // An empty group won't be shown.
                    return(new List <ProjectSectionSimple>());
                }

                var projectUpdateSectionsForPartners = projectWorkflowSectionGrouping.ProjectUpdateSections.Except(new List <ProjectUpdateSection> {
                    ProjectUpdateSection.Budget
                }).ToList();
                return(GetProjectUpdateSectionsImpl(projectUpdateBatch, projectUpdateSectionsForPartners, projectUpdateStatus, ignoreStatus));

            default:
                throw new ArgumentOutOfRangeException($"Unhandled Workflow Section Grouping: {projectWorkflowSectionGrouping.ToEnum}");
            }
        }
Beispiel #2
0
        public static bool IsPassingAllValidationRules(this ProjectUpdateBatch projectUpdateBatch)
        {
            bool areAllProjectGeospatialAreasValid = HttpRequestStorage.DatabaseEntities.GeospatialAreaTypes.ToList().All(geospatialAreaType => projectUpdateBatch.IsProjectGeospatialAreaValid(geospatialAreaType));

            return(projectUpdateBatch.AreProjectBasicsValid() &&
                   projectUpdateBatch.AreContactsValid() &&
                   projectUpdateBatch.AreExpendituresValid() &&
                   projectUpdateBatch.AreReportedPerformanceMeasuresValid() &&
                   projectUpdateBatch.IsProjectLocationSimpleValid() &&
                   projectUpdateBatch.AreProjectCustomAttributesValid(HttpRequestStorage.FirmaSession) &&
                   areAllProjectGeospatialAreasValid);
        }
        public static bool IsPassingAllValidationRules(this ProjectUpdateBatch projectUpdateBatch)
        {
            bool areAllProjectGeospatialAreasValid = HttpRequestStorage.DatabaseEntities.GeospatialAreaTypes.ToList().All(geospatialAreaType => projectUpdateBatch.IsProjectGeospatialAreaValid(geospatialAreaType));

            // 4/17/20 TK - We removed the ability to edit expenditures. No longer need to check for valid on them.
            // 5/28/2020 - SLG leaving in expenditures line for now to aid merges. We'll see if it helps.
            return(projectUpdateBatch.AreProjectBasicsValid() &&
                   projectUpdateBatch.AreContactsValid() &&
                   //projectUpdateBatch.AreExpendituresValid() &&
                   projectUpdateBatch.AreReportedPerformanceMeasuresValid() &&
                   projectUpdateBatch.IsProjectLocationSimpleValid() &&
                   projectUpdateBatch.AreProjectCustomAttributesValid(HttpRequestStorage.FirmaSession) &&
                   areAllProjectGeospatialAreasValid);
        }