private void SetTaxonomyLeaf(ProjectFirmaModels.Models.Project project, FirmaSession currentFirmaSession) { var currentTaxonomyLeaf = project.GetTaxonomyLeaf(); // Are we attempting to change the TaxonomyLeaf away from what it is either already overridden to, // or away from what it currently calculates to? if (currentTaxonomyLeaf?.TaxonomyLeafID != this.TaxonomyLeafID) { // If so, we need a deliberate override. project.OverrideTaxonomyLeafID = this.TaxonomyLeafID; } // Immediate check for problems project.GetTaxonomyLeaf(); }
public EditProjectViewModel(ProjectFirmaModels.Models.Project project, bool hasExistingProjectUpdate) { TaxonomyLeafID = project.GetTaxonomyLeaf().TaxonomyLeafID; SecondaryProjectTaxonomyLeafIDs = project.SecondaryProjectTaxonomyLeafs.Select(x => x.TaxonomyLeafID); ProjectID = project.ProjectID; ProjectName = project.ProjectName; ProjectDescription = project.ProjectDescription; ProjectStageID = project.ProjectStageID; OldProjectStageID = project.ProjectStageID; ImplementationStartYear = project.ImplementationStartYear; PlanningDesignStartYear = project.PlanningDesignStartYear; CompletionYear = project.CompletionYear; HasExistingProjectUpdate = hasExistingProjectUpdate; BpaProjectNumber = project.BpaProjectNumber; }
public BasicsViewModel(ProjectFirmaModels.Models.Project project) { TaxonomyLeafID = project.GetTaxonomyLeaf().TaxonomyLeafID; SecondaryProjectTaxonomyLeafIDs = project.SecondaryProjectTaxonomyLeafs.Select(x => x.TaxonomyLeafID); ProjectID = project.ProjectID; ProjectName = project.ProjectName; ProjectDescription = project.ProjectDescription; ProjectStageID = project.ProjectStageID; PlanningDesignStartYear = project.PlanningDesignStartYear; ImplementationStartYear = project.ImplementationStartYear; CompletionYear = project.CompletionYear; ProjectCategoryEnum = project.ProjectCategory.ToEnum; Comments = project.BasicsComment; BpaProjectNumber = project.BpaProjectNumber; }
public ProjectMapPopupViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, bool showDetailedInformation) { //Project = project; DisplayName = project.GetDisplayName(); ProjectUrl = project.GetDetailUrl(); KeyPhoto = project.GetKeyPhoto(); Duration = project.GetDuration(); ProjectStage = project.ProjectStage; TaxonomyLeaf = project.GetTaxonomyLeaf(); EstimatedTotalCost = project.GetEstimatedTotalRegardlessOfFundingType().HasValue ? project.GetEstimatedTotalRegardlessOfFundingType().ToStringCurrency() : "Unknown"; var dict = new Dictionary <ProjectFirmaModels.Models.ClassificationSystem, string>(); project.ProjectClassifications.Select(x => x.Classification.ClassificationSystem).Distinct(new HavePrimaryKeyComparer <ProjectFirmaModels.Models.ClassificationSystem>()).ToList().ForEach(x => dict.Add(x, string.Join(", ", project.ProjectClassifications.Select(y => y.Classification).Where(y => y.ClassificationSystem == x).Select(y => y.GetDisplayName()).ToList()))); ClassificationsBySystem = dict; OfferFactSheetLink = OfferProjectFactSheetLinkFeature.OfferProjectFactSheetLink(currentFirmaSession, project); FactSheetUrl = project.GetFactSheetUrl(); DetailLinkDescriptor = project.IsProposal() ? $"This {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} is a proposal. For description and expected results, see the" : $"For {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} expenditures & results, see the"; InitializeDisplayNames(); TaxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel(); ShowDetailedInformation = showDetailedInformation; }
public ProjectTaxonomyViewData(ProjectFirmaModels.Models.Project project, TaxonomyLevel taxonomyLevel) : this(project.GetTaxonomyLeaf()?.TaxonomyBranch.TaxonomyTrunk, project.GetTaxonomyLeaf()?.TaxonomyBranch, project.GetTaxonomyLeaf(), project, taxonomyLevel) { }
public BackwardLookingFactSheetViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, ProjectLocationSummaryMapInitJson projectLocationSummaryMapInitJson, GoogleChartJson projectFactSheetGoogleChart, List <GooglePieChartSlice> expenditureGooglePieChartSlices, List <string> chartColorRange, ProjectFirmaModels.Models.FirmaPage firmaPageFactSheet, List <TechnicalAssistanceParameter> technicalAssistanceParameters, bool withCustomAttributes, ProjectController.FactSheetPdfEnum factSheetPdfEnum) : base(currentFirmaSession, project) { PageTitle = project.GetDisplayName(); BreadCrumbTitle = "Fact Sheet"; EstimatedTotalCost = Project.GetEstimatedTotalRegardlessOfFundingType().HasValue ? Project.GetEstimatedTotalRegardlessOfFundingType().ToStringCurrency() : ""; NoFundingSourceIdentified = project.GetNoFundingSourceIdentifiedAmount() != null?Project.GetNoFundingSourceIdentifiedAmount().ToStringCurrency() : ""; ProjectedFunding = Project.GetProjectedFunding().ToStringCurrency(); PerformanceMeasureReportedValues = project.GetPerformanceMeasureReportedValues().GroupBy(x => x.PerformanceMeasure).OrderBy(x => x.Key.PerformanceMeasureSortOrder).ThenBy(x => x.Key.PerformanceMeasureDisplayName).ToList(); PerformanceMeasureExpectedValues = project.PerformanceMeasureExpecteds.GroupBy(x => x.PerformanceMeasure, new HavePrimaryKeyComparer <ProjectFirmaModels.Models.PerformanceMeasure>()) .OrderBy(x => x.Key.PerformanceMeasureSortOrder).ThenBy(x => x.Key.PerformanceMeasureDisplayName).ToList(); ShowExpectedPerformanceMeasures = MultiTenantHelpers.GetTenantAttributeFromCache().ShowExpectedPerformanceMeasuresOnFactSheet&& (project.ProjectStage == ProjectStage.Implementation || project.ProjectStage == ProjectStage.PostImplementation) && !PerformanceMeasureReportedValues.Any(); ChartID = $"fundingChartForProject{project.ProjectID}"; KeyPhoto = project.GetKeyPhoto(); ProjectImagesExceptKeyPhotoGroupedByTiming = project.ProjectImages.Where(x => !x.IsKeyPhoto && x.ProjectImageTiming != ProjectImageTiming.Unknown && !x.ExcludeFromFactSheet) .GroupBy(x => x.ProjectImageTiming) .OrderBy(x => x.Key.SortOrder) .ToList(); ProjectImagesPerTimingGroup = ProjectImagesExceptKeyPhotoGroupedByTiming.Count == 1 ? 6 : 2; Classifications = project.ProjectClassifications.Select(x => x.Classification).ToList().SortByOrderThenName().ToList(); ProjectLocationSummaryMapInitJson = projectLocationSummaryMapInitJson; GoogleChartJson = projectFactSheetGoogleChart; ExpenditureGooglePieChartSlices = expenditureGooglePieChartSlices; ChartColorRange = chartColorRange; //Dynamically resize chart based on how much space the legend requires CalculatedChartHeight = 350 - ExpenditureGooglePieChartSlices.Count * 19; FactSheetPdfUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.FactSheetPdf(project)); FactSheetWithCustomAttributesPdfUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.FactSheetWithCustomAttributesPdf(project)); if (project.GetTaxonomyLeaf() == null) { TaxonomyColor = "blue"; } else { switch (MultiTenantHelpers.GetTaxonomyLevel().ToEnum) { case TaxonomyLevelEnum.Leaf: TaxonomyColor = project.GetTaxonomyLeaf().ThemeColor; break; case TaxonomyLevelEnum.Branch: TaxonomyColor = project.GetTaxonomyLeaf().TaxonomyBranch.ThemeColor; break; case TaxonomyLevelEnum.Trunk: TaxonomyColor = project.GetTaxonomyLeaf().TaxonomyBranch.TaxonomyTrunk.ThemeColor; break; } } TaxonomyLeafName = project.GetTaxonomyLeaf() == null ? $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Taxonomy Not Set" : project.GetTaxonomyLeaf().GetDisplayName(); TaxonomyBranchName = project.GetTaxonomyLeaf() == null ? $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Taxonomy Not Set" : project.GetTaxonomyLeaf().TaxonomyBranch.GetDisplayName(); TaxonomyLeafDisplayName = FieldDefinitionEnum.TaxonomyLeaf.ToType().GetFieldDefinitionLabel(); PrimaryContactPerson = project.GetPrimaryContact(); CustomFactSheetPageTextViewData = new ViewPageContentViewData(firmaPageFactSheet, false); TechnicalAssistanceParameters = technicalAssistanceParameters; TechnicalAssistanceRequests = project.TechnicalAssistanceRequests.ToList(); ViewableProjectCustomAttributeTypes = HttpRequestStorage.DatabaseEntities.ProjectCustomAttributeTypes.ToList().Where(x => x.HasViewPermission(currentFirmaSession) && x.IsViewableOnFactSheet).ToList(); ViewableProjectCustomAttributes = project.ProjectCustomAttributes.Where(x => x.ProjectCustomAttributeType.HasViewPermission(currentFirmaSession) && ViewableProjectCustomAttributeTypes.Contains(x.ProjectCustomAttributeType)).ToList(); WithCustomAttributes = withCustomAttributes; LastUpdated = project.LastUpdatedDate; FactSheetPdfEnum = factSheetPdfEnum; // No delay loading our fake image by default int fakeImageDelayInMilliseconds = 0; // When set the page is being rendered for PDF if (factSheetPdfEnum == ProjectController.FactSheetPdfEnum.Pdf) { // If we are printing for PDF, we have a fake 1x1 transparent image that we deliberately take time to load. This causes Headless Chrome // to delay printing the page until the map is ready to be viewed. // // We hope that 4 seconds is enough to allow the mapping components to load. Increase if they don't render properly. fakeImageDelayInMilliseconds = ForwardLookingFactSheetViewData.FactSheetPdfEmptyImageLoadDelayInMilliseconds; } FakeImageWithDelayUrl = new SitkaRoute <FakeImageController>(c => c.ReturnEmptyImageAfterDelayInMilliseconds(fakeImageDelayInMilliseconds)).BuildAbsoluteUrlHttpsFromExpression(); ProjectLocationIsProvided = project.ProjectLocationPoint != null || project.ProjectLocations.Any(); }