private static List <PerformanceMeasureReportedValue> GetPerformanceMeasureReportedValuesAndGridSpec(
     out PerformanceMeasureReportedValuesGridSpec gridSpec, PerformanceMeasure performanceMeasure,
     FirmaSession currentFirmaSession)
 {
     gridSpec = new PerformanceMeasureReportedValuesGridSpec(performanceMeasure);
     return(performanceMeasure.GetReportedPerformanceMeasureValues(currentFirmaSession));
 }
Beispiel #2
0
            public static PerformanceMeasureSubcategory Create(PerformanceMeasure performanceMeasure, string performanceMeasureSubcategoryName)
            {
                var performanceMeasureSubcategory = new PerformanceMeasureSubcategory(performanceMeasure, performanceMeasureSubcategoryName);

                performanceMeasure.PerformanceMeasureSubcategories.Add(performanceMeasureSubcategory);
                return(performanceMeasureSubcategory);
            }
Beispiel #3
0
 public PerformanceMeasureImportanceDto(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     Importance           = performanceMeasure.Importance;
     FileResources        = performanceMeasure.PerformanceMeasureImages.Select(x => new FileResourceDto(x.FileResourceInfo))
                            .ToList();
 }
        private PartialViewResult ViewResetChartConfiguration(PerformanceMeasure performanceMeasure, ConfirmDialogFormViewModel viewModel)
        {
            var confirmMessage = $"Are you sure you want to reset the chart configuration to the default?";

            var viewData = new ConfirmDialogFormViewData(confirmMessage, true);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel));
        }
Beispiel #5
0
 private static List <PerformanceMeasureSubcategoriesTotalReportedValue> GetSpendingByPerformanceMeasureByProjectAndGridSpec(
     out SpendingByPerformanceMeasureByProjectGridSpec gridSpec,
     PerformanceMeasure performanceMeasure,
     FirmaSession currentFirmaSession)
 {
     gridSpec = new SpendingByPerformanceMeasureByProjectGridSpec(performanceMeasure);
     return(PerformanceMeasureModelExtensions.SubcategoriesTotalReportedValues(currentFirmaSession, performanceMeasure));
 }
Beispiel #6
0
 public PerformanceMeasureSimpleDto(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureID                 = performanceMeasure.PerformanceMeasureID;
     PerformanceMeasureDisplayName        = performanceMeasure.PerformanceMeasureDisplayName;
     PerformanceMeasureTypeName           = performanceMeasure.PerformanceMeasureType.PerformanceMeasureTypeDisplayName;
     PerformanceMeasureDataSourceTypeName = performanceMeasure.PerformanceMeasureDataSourceType.PerformanceMeasureDataSourceTypeDisplayName;
     MeasurementUnitTypeName              = performanceMeasure.MeasurementUnitType.MeasurementUnitTypeDisplayName;
 }
Beispiel #7
0
        private PartialViewResult ViewEdit(EditViewModel viewModel, PerformanceMeasure performanceMeasure)
        {
            var associatePerformanceMeasureTaxonomyLevel = MultiTenantHelpers.GetAssociatePerformanceMeasureTaxonomyLevel();
            var taxonomyBranchSimples = associatePerformanceMeasureTaxonomyLevel.GetTaxonomyTiers().OrderBy(p => p.DisplayName).ToList().Select(x => new TaxonomyTier(x)).ToList();
            var viewData = new EditViewData(new PerformanceMeasureSimple(performanceMeasure), taxonomyBranchSimples, associatePerformanceMeasureTaxonomyLevel);

            return(RazorPartialView <Edit, EditViewData, EditViewModel>(viewData, viewModel));
        }
        private List <int> GetSelectedGeospatialAreasFromPerformanceMeasure(PerformanceMeasure performanceMeasure)
        {
            var geospatialAreaIDs = new List <int>();

            geospatialAreaIDs.AddRange(HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID).Select(x => x.GeospatialAreaID).ToList());
            geospatialAreaIDs.AddRange(HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureNoTargets.Where(x => x.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID).Select(x => x.GeospatialAreaID).ToList());
            geospatialAreaIDs.AddRange(HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureFixedTargets.Where(x => x.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID).Select(x => x.GeospatialAreaID).ToList());
            return(geospatialAreaIDs);
        }
Beispiel #9
0
            public static PerformanceMeasure Create()
            {
                var performanceMeasure = new PerformanceMeasure("Foo", MeasurementUnitType.Acres, PerformanceMeasureType.Action, false, false, true, PerformanceMeasureDataSourceType.Project)
                {
                    PerformanceMeasureSubcategories = new List <PerformanceMeasureSubcategory>()
                };

                return(performanceMeasure);
            }
 public PerformanceMeasureSimple(PerformanceMeasure performanceMeasure)
     : this(
         performanceMeasure.PerformanceMeasureID,
         performanceMeasure.MeasurementUnitTypeID,
         performanceMeasure.PerformanceMeasureDisplayName,
         performanceMeasure.MeasurementUnitType.MeasurementUnitTypeDisplayName,
         performanceMeasure.HasRealSubcategories,
         performanceMeasure.GetDefinitionAndGuidanceUrl())
 {
 }
 public PerformanceMeasureBasicsDto(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureID                 = performanceMeasure.PerformanceMeasureID;
     PerformanceMeasureDisplayName        = performanceMeasure.PerformanceMeasureDisplayName;
     PerformanceMeasureDefinition         = performanceMeasure.PerformanceMeasureDefinition;
     PerformanceMeasureTypeName           = performanceMeasure.PerformanceMeasureType.PerformanceMeasureTypeDisplayName;
     PerformanceMeasureDataSourceTypeName = performanceMeasure.PerformanceMeasureDataSourceType.PerformanceMeasureDataSourceTypeDisplayName;
     MeasurementUnitTypeName              = performanceMeasure.MeasurementUnitType.MeasurementUnitTypeDisplayName;
     IsSummable = performanceMeasure.IsSummable;
 }
Beispiel #12
0
            public static PerformanceMeasure Create()
            {
                var randomGuid = Guid.NewGuid();
                var performanceMeasureDisplayName = $"PerformanceMeasureFakeName_{randomGuid}";
                var performanceMeasure            = new PerformanceMeasure(performanceMeasureDisplayName, MeasurementUnitType.Acres, PerformanceMeasureType.Action, false, PerformanceMeasureDataSourceType.Project, false)
                {
                    PerformanceMeasureSubcategories = new List <PerformanceMeasureSubcategory>()
                };

                return(performanceMeasure);
            }
Beispiel #13
0
            public static PerformanceMeasureSubcategory CreateWithSubcategoryOptions(PerformanceMeasure performanceMeasure, int performanceMeasureSubcategoryID, string performanceMeasureSubcategoryName)
            {
                var performanceMeasureSubcategory = Create(performanceMeasure, performanceMeasureSubcategoryName);

                performanceMeasureSubcategory.PerformanceMeasureSubcategoryID = performanceMeasureSubcategoryID;
                var subcategoryOptionIDBase = performanceMeasureSubcategoryID * 10;
                var subcategoryOption1      = TestFramework.TestPerformanceMeasureSubcategoryOption.Create(subcategoryOptionIDBase + 1, performanceMeasureSubcategory, $"{performanceMeasureSubcategoryName}Option1");
                var subcategoryOption2      = TestFramework.TestPerformanceMeasureSubcategoryOption.Create(subcategoryOptionIDBase + 2, performanceMeasureSubcategory, $"{performanceMeasureSubcategoryName}Option2");
                var subcategoryOption3      = TestFramework.TestPerformanceMeasureSubcategoryOption.Create(subcategoryOptionIDBase + 3, performanceMeasureSubcategory, $"{performanceMeasureSubcategoryName}Option3");

                return(performanceMeasureSubcategory);
            }
        private PartialViewResult ViewDeletePerformanceMeasure(PerformanceMeasure performanceMeasure, ConfirmDialogFormViewModel viewModel)
        {
            var hasNoAssociations = !performanceMeasure.PerformanceMeasureSubcategories.SelectMany(x => x.PerformanceMeasureSubcategoryOptions).Any(x => x.HasDependentObjects());
            var confirmMessage    = hasNoAssociations
                ? $"<p>Are you sure you want to delete {MultiTenantHelpers.GetPerformanceMeasureName()} \"{performanceMeasure.PerformanceMeasureDisplayName}\"?</p>"
                : String.Format("<p>Are you sure you want to delete {0} \"{1}\"?</p><p>Deleting this {0} will <strong>delete all associated reported data</strong>, and this action cannot be undone. Click {2} to review.</p>",
                                MultiTenantHelpers.GetPerformanceMeasureName(),
                                performanceMeasure.PerformanceMeasureDisplayName,
                                SitkaRoute <PerformanceMeasureController> .BuildLinkFromExpression(x => x.Detail(performanceMeasure), "here"));

            var viewData = new ConfirmDialogFormViewData(confirmMessage);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel));
        }
        private PartialViewResult ViewDelete(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure, ConfirmDialogFormViewModel viewModel)
        {
            var geospatialAreaPerformanceMeasureTargets =
                HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x =>
                                                                                                                 x.GeospatialAreaID == geospatialArea.GeospatialAreaID &&
                                                                                                                 x.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID);


            var confirmMessage =
                $"Are you sure you want to delete all targets associated with this {FieldDefinitionEnum.GeospatialArea.ToType().GetFieldDefinitionLabel()} '{geospatialArea.GeospatialAreaShortName}'?";

            var viewData = new ConfirmDialogFormViewData(confirmMessage, true);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel));
        }
 public PerformanceMeasureDto(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureID          = performanceMeasure.PerformanceMeasureID;
     PerformanceMeasureDisplayName = performanceMeasure.PerformanceMeasureDisplayName;
     PerformanceMeasureDefinition  = performanceMeasure.PerformanceMeasureDefinition;
     CriticalDefinitions           = performanceMeasure.CriticalDefinitions;
     ProjectReporting                     = performanceMeasure.ProjectReporting;
     PerformanceMeasureTypeName           = performanceMeasure.PerformanceMeasureType.PerformanceMeasureTypeDisplayName;
     PerformanceMeasureDataSourceTypeName = performanceMeasure.PerformanceMeasureDataSourceType.PerformanceMeasureDataSourceTypeDisplayName;
     MeasurementUnitTypeName              = performanceMeasure.MeasurementUnitType.MeasurementUnitTypeDisplayName;
     PerformanceMeasureSubcategories      = performanceMeasure.PerformanceMeasureSubcategories
                                            .Select(x => new PerformanceMeasureSubcategoryDto(x)).ToList();
     CanBeChartedCumulatively = performanceMeasure.CanBeChartedCumulatively;
     IsSummable = performanceMeasure.IsSummable;
 }
        public decimal?CalculateWeightedTotalExpenditure()
        {
            var reportedValuesForAllSubcategories = PerformanceMeasure.GetReportedPerformanceMeasureValues(Project)
                                                    .Where(x => FirmaDateUtilities.DateIsInReportingRange(x.CalendarYear))
                                                    .Sum(x => x.ReportedValue ?? 0);

            if (Math.Abs(reportedValuesForAllSubcategories) < double.Epsilon)
            {
                return(null);
            }

            var projectGrantAllocationExpenditures = Project.ProjectGrantAllocationExpenditures.Where(x => FirmaDateUtilities.DateIsInReportingRange(x.CalendarYear)).ToList();
            var weight = TotalReportedValue / reportedValuesForAllSubcategories;

            return(projectGrantAllocationExpenditures.Sum(x => x.ExpenditureAmount) * Convert.ToDecimal(weight));
        }
        private ActionResult ViewEdit(GeospatialArea geospatialArea,
                                      PerformanceMeasure performanceMeasure,
                                      EditPerformanceMeasureTargetsViewModel viewModel)
        {
            var performanceMeasureTargetValueTypes = PerformanceMeasureTargetValueType.All.ToList();
            var reportingPeriods           = performanceMeasure.GetPerformanceMeasureReportingPeriodsFromTargetsAndActualsAndGeospatialAreaTargets(geospatialArea);
            var defaultReportingPeriodYear = reportingPeriods.Any()
                ? reportingPeriods.Max(x => x.PerformanceMeasureReportingPeriodCalendarYear) + 1
                : DateTime.Now.Year;
            var viewDataForAngular = new EditPerformanceMeasureTargetsViewDataForAngular(performanceMeasure,
                                                                                         defaultReportingPeriodYear,
                                                                                         performanceMeasureTargetValueTypes,
                                                                                         true);
            var viewData = new EditPerformanceMeasureTargetsViewData(performanceMeasure, viewDataForAngular, EditPerformanceMeasureTargetsViewData.PerformanceMeasureTargetType.TargetByGeospatialArea);

            return(RazorPartialView <EditPerformanceMeasureTargets, EditPerformanceMeasureTargetsViewData, EditPerformanceMeasureTargetsViewModel>(viewData, viewModel));
        }
        private PartialViewResult ViewAddGeospatialAreaToPerformanceMeasure(PerformanceMeasure performanceMeasure, AddGeospatialAreaToPerformanceMeasureViewModel viewModel)
        {
            var geospatialAreaTypeSimples = HttpRequestStorage.DatabaseEntities.GeospatialAreaTypes.ToList().Select(x => new GeospatialAreaTypeSimple(x)).ToList();
            //build list of geospatial areas and remove any we have already setup a connection to this performance measure
            var geospatialAreaSimples = HttpRequestStorage.DatabaseEntities.vGeospatialAreas
                                        .Where(x => x.TenantID == HttpRequestStorage.DatabaseEntities.TenantID)
                                        .ToList().Select(x => new GeospatialAreaSimple(x)).ToList();//todo: probably want this data coming from an AJAX call
            var selectedGeospatialAreas       = GetSelectedGeospatialAreasFromPerformanceMeasure(performanceMeasure);
            var selectedGeospatialAreaSimples = geospatialAreaSimples.Where(x => selectedGeospatialAreas.Contains(x.GeospatialAreaID)).ToList();
            var setToRemove = new HashSet <GeospatialAreaSimple>(selectedGeospatialAreaSimples);

            geospatialAreaSimples.RemoveAll(x => setToRemove.Contains(x));

            var viewDataForAngular = new AddGeospatialAreaToPerformanceMeasureViewDataForAngular(performanceMeasure, geospatialAreaTypeSimples, geospatialAreaSimples);
            var viewData           = new AddGeospatialAreaToPerformanceMeasureViewData(performanceMeasure, viewDataForAngular);

            return(RazorPartialView <AddGeospatialAreaToPerformanceMeasure, AddGeospatialAreaToPerformanceMeasureViewData, AddGeospatialAreaToPerformanceMeasureViewModel>(viewData, viewModel));
        }
        public WebServicePerformanceMeasure(PerformanceMeasure performanceMeasure)
        {
            PerformanceMeasureID    = performanceMeasure.PerformanceMeasureID;
            PerformanceMeasureName  = performanceMeasure.PerformanceMeasureDisplayName;
            PerformanceMeasureUnits = performanceMeasure.MeasurementUnitType.MeasurementUnitTypeDisplayName;

            if (performanceMeasure.HasRealSubcategories())
            {
                var currentSubcategoryIndex = 1;
                foreach (var performanceMeasureSubcategory in performanceMeasure.PerformanceMeasureSubcategories)
                {
                    if (currentSubcategoryIndex == 1)
                    {
                        PMSubcategoryName1        = performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName;
                        PMSubcategoryOptionCount1 = performanceMeasureSubcategory.PerformanceMeasureSubcategoryOptions.Count;
                    }
                    else if (currentSubcategoryIndex == 2)
                    {
                        PMSubcategoryName2        = performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName;
                        PMSubcategoryOptionCount2 = performanceMeasureSubcategory.PerformanceMeasureSubcategoryOptions.Count;
                    }
                    else if (currentSubcategoryIndex == 3)
                    {
                        PMSubcategoryName3        = performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName;
                        PMSubcategoryOptionCount3 = performanceMeasureSubcategory.PerformanceMeasureSubcategoryOptions.Count;
                    }
                    else if (currentSubcategoryIndex == 4)
                    {
                        PMSubcategoryName4        = performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName;
                        PMSubcategoryOptionCount4 = performanceMeasureSubcategory.PerformanceMeasureSubcategoryOptions.Count;
                    }
                    else
                    {
                        throw new NotImplementedException($"Cannot handle more than four subcategories on a {FieldDefinitionEnum.PerformanceMeasure.ToType().GetFieldDefinitionLabel()}");
                    }
                    currentSubcategoryIndex++;
                }
            }
        }
        public ActionResult New(EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel));
            }

            var performanceMeasure = new PerformanceMeasure(default(string), default(int), default(int), false,
                                                            PerformanceMeasureDataSourceType.Project.PerformanceMeasureDataSourceTypeID, false);

            viewModel.UpdateModel(performanceMeasure, CurrentFirmaSession);

            var defaultSubcategory = new PerformanceMeasureSubcategory(performanceMeasure, "Default")
            {
                GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID
            };
            var defaultSubcategoryChartConfigurationJson =
                performanceMeasure.GetDefaultPerformanceMeasureChartConfigurationJson();

            defaultSubcategory.ChartConfigurationJson =
                JObject.FromObject(defaultSubcategoryChartConfigurationJson).ToString();
            if (performanceMeasure.CanBeChartedCumulatively)
            {
                var defaultPerformanceMeasureChartConfigurationJson =
                    performanceMeasure.GetDefaultPerformanceMeasureChartConfigurationJson();
                defaultSubcategory.CumulativeChartConfigurationJson =
                    JObject.FromObject(defaultPerformanceMeasureChartConfigurationJson).ToString();
                defaultSubcategory.CumulativeGoogleChartTypeID = performanceMeasure.HasTargets()
                    ? GoogleChartType.ComboChart.GoogleChartTypeID
                    : GoogleChartType.ColumnChart.GoogleChartTypeID;
            }

            new PerformanceMeasureSubcategoryOption(defaultSubcategory, "Default", false);
            HttpRequestStorage.DatabaseEntities.AllPerformanceMeasures.Add(performanceMeasure);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay(
                $"New {MultiTenantHelpers.GetPerformanceMeasureName()} '{performanceMeasure.GetDisplayNameAsUrl()}' successfully created!");
            return(new ModalDialogFormJsonResult());
        }
Beispiel #22
0
        private static void PrintClusters(ISet <DataPoint> instances, ILinkageCriterion <DataPoint> linkage, string name)
        {
            var perfMeasure = new PerformanceMeasure();

            perfMeasure.Start();
            var clusteringAlg = new AgglomerativeClusteringAlgorithm <DataPoint>(linkage);
            var clustering    = clusteringAlg.GetClustering(instances);

            perfMeasure.Stop();

            Console.WriteLine("_____________________________________________");
            Console.WriteLine(name);
            Console.WriteLine(perfMeasure);
            foreach (var clusterSet in clustering)
            {
                Console.WriteLine($"Clusters at distance: {clusterSet.Dissimilarity:0.00} ({clusterSet.Count})");
                foreach (var cluster in clusterSet)
                {
                    Console.WriteLine($" - {cluster}");
                }
            }

            clustering.SaveD3DendrogramFile(Path.GetFullPath($"{name}.json"), formatting: Formatting.Indented);
        }
Beispiel #23
0
            public static PerformanceMeasureReportingPeriod Create(PerformanceMeasure performanceMeasure, int calendarYear)
            {
                var performanceMeasureReportingPeriod = new PerformanceMeasureReportingPeriod(calendarYear, calendarYear.ToString());

                return(performanceMeasureReportingPeriod);
            }
Beispiel #24
0
 public ReportingCategoryForDisplay(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureSubcategoryOptionID = null;
     DisplayName = performanceMeasure.PerformanceMeasureDisplayName;
     SortOrder   = 1;
 }
Beispiel #25
0
            public static ProjectTypePerformanceMeasure Create(ProjectType projectType, PerformanceMeasure performanceMeasure)
            {
                var projectTypePerformanceMeasure = ProjectTypePerformanceMeasure.CreateNewBlank(projectType, performanceMeasure);

                return(projectTypePerformanceMeasure);
            }
 private static List <PerformanceMeasureExpected> GetPerformanceMeasureExpectedsAndGridSpec(
     out PerformanceMeasureExpectedGridSpec gridSpec, PerformanceMeasure performanceMeasure)
 {
     gridSpec = new PerformanceMeasureExpectedGridSpec(performanceMeasure);
     return(performanceMeasure.PerformanceMeasureExpecteds.ToList());
 }
            public static PerformanceMeasureExpected Create(int performanceMeasureExpectedID, Project project, PerformanceMeasure performanceMeasure, double expectedValue)
            {
                var performanceMeasureExpected = PerformanceMeasureExpected.CreateNewBlank(project, performanceMeasure);

                performanceMeasureExpected.PerformanceMeasureExpectedID = performanceMeasureExpectedID;
                performanceMeasureExpected.ExpectedValue = expectedValue;
                return(performanceMeasureExpected);
            }
Beispiel #28
0
            public static PerformanceMeasureReportingPeriod Create(PerformanceMeasure performanceMeasure)
            {
                var performanceMeasureReportingPeriod = new PerformanceMeasureReportingPeriod(DateTime.Now.Year, DateTime.Now.Year.ToString());

                return(performanceMeasureReportingPeriod);
            }
 public PerformanceMeasureProjectReportingDto(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     ProjectReporting     = performanceMeasure.ProjectReporting;
 }
        public IHttpActionResult PostPerformanceMeasure(string apiKey, [FromBody] PerformanceMeasureDto performanceMeasureDto)
        {
            Check.Require(apiKey == FirmaWebApiConfiguration.PsInfoApiKey, "Unrecognized api key!");
            var performanceMeasureType           = MapPerformanceMeasureTypeNameToPerformanceMeasureType(performanceMeasureDto.PerformanceMeasureTypeName);
            var performanceMeasureDataSourceType = MapPerformanceMeasureDataSourceTypeNameToPerformanceMeasureDataSourceType(performanceMeasureDto.PerformanceMeasureDataSourceTypeName);
            var measurementUnitType = MapMeasurementUnitTypeNameToMeasurementUnitType(performanceMeasureDto.MeasurementUnitTypeName);

            if (performanceMeasureType == null)
            {
                return(BadRequest($"Invalid Performance Measure Type: {performanceMeasureDto.PerformanceMeasureTypeName}"));
            }
            if (performanceMeasureDataSourceType == null)
            {
                return(BadRequest($"Invalid Performance Measure Data Source Type: {performanceMeasureDto.PerformanceMeasureDataSourceTypeName}"));
            }
            if (measurementUnitType == null)
            {
                return(BadRequest($"Invalid Measurement Unit: {performanceMeasureDto.MeasurementUnitTypeName}"));
            }
            var performanceMeasure = new PerformanceMeasure(performanceMeasureDto.PerformanceMeasureDisplayName,
                                                            measurementUnitType.MeasurementUnitTypeID, performanceMeasureType.PerformanceMeasureTypeID,
                                                            performanceMeasureDto.IsSummable, performanceMeasureDataSourceType.PerformanceMeasureDataSourceTypeID, performanceMeasureDto.CanBeChartedCumulatively, false);

            performanceMeasure.CriticalDefinitions          = performanceMeasureDto.CriticalDefinitions;
            performanceMeasure.PerformanceMeasureDefinition = performanceMeasureDto.PerformanceMeasureDefinition;
            performanceMeasure.ProjectReporting             = performanceMeasureDto.ProjectReporting;
            performanceMeasure.Importance            = performanceMeasureDto.Importance;
            performanceMeasure.AdditionalInformation = performanceMeasureDto.AdditionalInformation;

            // create file resources for images in the Importance rich text
            var fileResourceDtos      = performanceMeasureDto.FileResources;
            var fileResourceMimeTypes = fileResourceDtos.ToDictionary(x => new { x.FileResourceGUID, x.FileResourceMimeTypeName },
                                                                      x => MapFileResourceMimeTypeNameToFileResourceMimeType(x.FileResourceMimeTypeName));

            if (fileResourceMimeTypes.Values.Any(x => x == null))
            {
                var errors =
                    fileResourceMimeTypes.Where(x => x.Value == null).Select(x =>
                                                                             $"Invalid File Resource Mime Type '{x.Key.FileResourceMimeTypeName}' for '{x.Key.FileResourceGUID}'").ToList();
                return(BadRequest(string.Join("\r\n", errors)));
            }
            var peopleDictionary         = _databaseEntities.People.ToDictionary(x => x.Email);
            var performanceMeasureImages = fileResourceDtos.Select(x =>
            {
                var fileResourceMimeTypeID = fileResourceMimeTypes.Single(y => y.Key.FileResourceGUID == x.FileResourceGUID).Value.FileResourceMimeTypeID;
                var personID         = peopleDictionary.ContainsKey(x.Email) ? peopleDictionary[x.Email].PersonID : 5278;
                var fileResourceInfo = new FileResourceInfo(fileResourceMimeTypeID, x.OriginalBaseFilename, x.OriginalFileExtension, x.FileResourceGUID, personID, x.CreateDate);
                fileResourceInfo.FileResourceDatas.Add(new FileResourceData(fileResourceInfo.FileResourceInfoID, x.FileResourceData));
                var performanceMeasureImage = new PerformanceMeasureImage(performanceMeasure, fileResourceInfo);
                return(performanceMeasureImage);
            }).ToList();

            var tenantID = Tenant.ActionAgendaForPugetSound.TenantID;

            foreach (var performanceMeasureSubcategoryDto in performanceMeasureDto.PerformanceMeasureSubcategories)
            {
                var googleChartType = MapGoogleChartTypeNameToGoogleChartType(performanceMeasureSubcategoryDto.GoogleChartTypeName);
                if (googleChartType == null)
                {
                    return(BadRequest($"Invalid Google Chart Type '{performanceMeasureSubcategoryDto.GoogleChartTypeName}' for Subcategory '{performanceMeasureSubcategoryDto.PerformanceMeasureSubcategoryName}'"));
                }
                var performanceMeasureSubcategory = new PerformanceMeasureSubcategory(performanceMeasure, performanceMeasureSubcategoryDto.PerformanceMeasureSubcategoryName)
                {
                    ChartConfigurationJson = performanceMeasureSubcategoryDto.ChartConfigurationJson,
                    GoogleChartTypeID      = googleChartType.GoogleChartTypeID,
                    TenantID = tenantID
                };
                foreach (var performanceMeasureSubcategoryOptionDto in performanceMeasureSubcategoryDto.PerformanceMeasureSubcategoryOptions)
                {
                    var performanceMeasureSubcategoryOption = new PerformanceMeasureSubcategoryOption(performanceMeasureSubcategory, performanceMeasureSubcategoryOptionDto.PerformanceMeasureSubcategoryOptionName, false)
                    {
                        TenantID = tenantID
                    };
                }
            }
            _databaseEntities.AllPerformanceMeasures.Add(performanceMeasure);
            _databaseEntities.SaveChangesWithNoAuditing(tenantID);
            var performanceMeasureReloaded = new PerformanceMeasureDto(performanceMeasure);

            return(Ok(performanceMeasureReloaded));
        }