public static PerformanceMeasureChartViewData GetPerformanceMeasureChartViewData(this Organization organization, PerformanceMeasure performanceMeasure, FirmaSession firmaSession) { var projects = organization.GetAllActiveProjectsAndProposals(firmaSession).ToList(); return(new PerformanceMeasureChartViewData(performanceMeasure, firmaSession, false, projects)); }
private static MapInitJson GetMapInitJson(Organization organization, out bool hasSpatialData, Person person) { hasSpatialData = false; var layers = new List <LayerGeoJson>(); if (organization.OrganizationBoundary != null) { hasSpatialData = true; layers.Add(new LayerGeoJson("Organization Boundary", organization.OrganizationBoundaryToFeatureCollection(), organization.OrganizationType?.LegendColor ?? FirmaHelpers.DefaultColorRange.First(), 1, LayerInitialVisibility.Show)); } var allActiveProjectsAndProposals = organization.GetAllActiveProjectsAndProposals(person).Where(x => x.ProjectStage.ShouldShowOnMap()).ToList(); var projectsAsSimpleLocations = allActiveProjectsAndProposals.Where(x => x.ProjectLocationSimpleType != ProjectLocationSimpleType.None).ToList(); var projectSimpleLocationsFeatureCollection = new FeatureCollection(); var allProjectGrantAllocationExpenditures = HttpRequestStorage.DatabaseEntities.ProjectGrantAllocationExpenditures.ToList(); var projectGrantAllocationExpenditureDict = allProjectGrantAllocationExpenditures.GroupBy(x => x.ProjectID).ToDictionary(x => x.Key, y => y.ToList()); projectSimpleLocationsFeatureCollection.Features.AddRange(projectsAsSimpleLocations.Select(x => { var feature = x.MakePointFeatureWithRelevantProperties(x.ProjectLocationPoint, true, true, FieldDefinition.Organization.GetFieldDefinitionLabel(), FieldDefinition.Organization.GetFieldDefinitionLabelPluralized(), projectGrantAllocationExpenditureDict); feature.Properties["FeatureColor"] = "#99b3ff"; return(feature); }).ToList()); if (projectSimpleLocationsFeatureCollection.Features.Any()) { hasSpatialData = true; layers.Add(new LayerGeoJson("Projects", projectSimpleLocationsFeatureCollection, "blue", 1, LayerInitialVisibility.Show)); } var projectDetailLocationsFeatureCollection = allActiveProjectsAndProposals.SelectMany(x => x.GetProjectLocationDetails()).ToGeoJsonFeatureCollection(); if (projectDetailLocationsFeatureCollection.Features.Any()) { hasSpatialData = true; layers.Add(new LayerGeoJson($"{FieldDefinition.Project.GetFieldDefinitionLabel()} Detailed Mapping", projectDetailLocationsFeatureCollection, "blue", 1, LayerInitialVisibility.Hide)); } var boundingBox = BoundingBox.MakeBoundingBoxFromLayerGeoJsonList(layers); layers.AddRange(MapInitJson.GetAllGeospatialAreaMapLayers(LayerInitialVisibility.Show)); return(new MapInitJson($"organization_{organization.OrganizationID}_Map", 10, layers, boundingBox)); }