Exemplo n.º 1
0
        public DetailViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.GeospatialArea geospatialArea,
                              MapInitJson mapInitJson, LayerGeoJson projectLocationsLayerGeoJson, ViewGoogleChartViewData viewGoogleChartViewData,
                              List <ProjectFirmaModels.Models.PerformanceMeasure> performanceMeasures,
                              List <ProjectCustomGridConfiguration> projectCustomDefaultGridConfigurations) : base(currentFirmaSession)
        {
            GeospatialArea = geospatialArea;
            MapInitJson    = mapInitJson;
            ProjectLocationsLayerGeoJson = projectLocationsLayerGeoJson;
            ViewGoogleChartViewData      = viewGoogleChartViewData;
            PageTitle = geospatialArea.GeospatialAreaName;
            GeospatialAreaTypeName           = geospatialArea.GeospatialAreaType.GeospatialAreaTypeName;
            GeospatialAreaTypeNamePluralized = geospatialArea.GeospatialAreaType.GeospatialAreaTypeNamePluralized;
            EntityName = $"{GeospatialAreaTypeName}";
            UserHasGeospatialAreaManagePermissions = new GeospatialAreaManageFeature().HasPermissionByFirmaSession(currentFirmaSession);
            IndexUrl = SitkaRoute <GeospatialAreaController> .BuildUrlFromExpression(x => x.Index(geospatialArea.GeospatialAreaType));

            var projectDetails = HttpRequestStorage.DatabaseEntities.vProjectDetails.ToDictionary(x => x.ProjectID);

            ProjectCustomDefaultGridSpec = new ProjectCustomGridSpec(currentFirmaSession, projectCustomDefaultGridConfigurations, ProjectCustomGridType.Default.ToEnum, projectDetails, currentFirmaSession.Tenant)
            {
                ObjectNameSingular = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}", ObjectNamePlural = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}", SaveFiltersInCookie = true
            };

            ProjectCustomDefaultGridName    = "geospatialAreaProjectListGrid";
            ProjectCustomDefaultGridDataUrl = SitkaRoute <ProjectCustomGridController> .BuildUrlFromExpression(tc => tc.GeospatialAreaProjectsGridJsonData(geospatialArea));

            PerformanceMeasureChartViewDatas = performanceMeasures.Select(x => geospatialArea.GetPerformanceMeasureChartViewData(x, currentFirmaSession)).ToList();

            GeospatialAreaDescriptionViewPageContentViewData = new ViewPageContentViewData(geospatialArea, currentFirmaSession);
        }
Exemplo n.º 2
0
        public PerformanceMeasureChartViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
                                               int height,
                                               FirmaSession currentFirmaSession,
                                               bool showLastUpdatedDate,
                                               bool fromPerformanceMeasureDetailPage,
                                               List<ProjectFirmaModels.Models.Project> projects,
                                               string chartUniqueName,
                                               ProjectFirmaModels.Models.GeospatialArea geospatialArea)
        {
            PerformanceMeasure = performanceMeasure;
            HyperlinkPerformanceMeasureName = !fromPerformanceMeasureDetailPage;

            GoogleChartJsons = performanceMeasure.GetGoogleChartJsonDictionary(geospatialArea, projects, chartUniqueName);

            var performanceMeasureActuals = PerformanceMeasure.PerformanceMeasureActuals.Where(x => projects.Contains(x.Project)).ToList();
            ChartTotal = performanceMeasureActuals.Any() ? performanceMeasureActuals.Sum(x => x.ActualValue) : (double?) null;
            ChartTotalFormatted = PerformanceMeasure.MeasurementUnitType.DisplayValue(ChartTotal);

            var currentPersonHasManagePermission = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);
            CanManagePerformanceMeasures = currentPersonHasManagePermission && fromPerformanceMeasureDetailPage;

            ShowLastUpdatedDate = showLastUpdatedDate;
            ChartTitle = performanceMeasure.GetDisplayName();
            ViewGoogleChartViewData = new ViewGoogleChartViewData(GoogleChartJsons,
                ChartTitle,
                height,
                null,
                chartUniqueName,
                CanManagePerformanceMeasures,
                SitkaRoute<GoogleChartController>.BuildUrlFromExpression(c => c.DownloadPerformanceMeasureChartData()),
                true,
                true,
                performanceMeasure,
                HyperlinkPerformanceMeasureName);
        }
Exemplo n.º 3
0
 public ViewPageContentViewData(ProjectFirmaModels.Models.GeospatialArea geospatialArea, FirmaSession currentFirmaSession)
 {
     FirmaPageContentHtmlString = geospatialArea.GetFirmaPageContentHtmlString();
     FirmaPageDisplayName       = geospatialArea.GetFirmaPageDisplayName();
     ShowEditButton             = new GeospatialAreaManageFeature().HasPermissionByFirmaSession(currentFirmaSession);
     HasPageContent             = geospatialArea.HasPageContent();
     EditPageContentUrl         = SitkaRoute <GeospatialAreaController> .BuildUrlFromExpression(t => t.EditDescriptionInDialog(geospatialArea));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectGeospatialArea(Project project, GeospatialArea geospatialArea) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectGeospatialAreaID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectID = project.ProjectID;
     this.Project   = project;
     project.ProjectGeospatialAreas.Add(this);
     this.GeospatialAreaID = geospatialArea.GeospatialAreaID;
     this.GeospatialArea   = geospatialArea;
     geospatialArea.ProjectGeospatialAreas.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PersonStewardGeospatialArea(Person person, GeospatialArea geospatialArea) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PersonStewardGeospatialAreaID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PersonID = person.PersonID;
     this.Person   = person;
     person.PersonStewardGeospatialAreas.Add(this);
     this.GeospatialAreaID = geospatialArea.GeospatialAreaID;
     this.GeospatialArea   = geospatialArea;
     geospatialArea.PersonStewardGeospatialAreas.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectGeospatialAreaUpdate(ProjectUpdateBatch projectUpdateBatch, GeospatialArea geospatialArea) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectGeospatialAreaUpdateID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectUpdateBatchID          = projectUpdateBatch.ProjectUpdateBatchID;
     this.ProjectUpdateBatch            = projectUpdateBatch;
     projectUpdateBatch.ProjectGeospatialAreaUpdates.Add(this);
     this.GeospatialAreaID = geospatialArea.GeospatialAreaID;
     this.GeospatialArea   = geospatialArea;
     geospatialArea.ProjectGeospatialAreaUpdates.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GeospatialAreaPerformanceMeasureNoTarget(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GeospatialAreaPerformanceMeasureNoTargetID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GeospatialAreaID = geospatialArea.GeospatialAreaID;
     this.GeospatialArea   = geospatialArea;
     geospatialArea.GeospatialAreaPerformanceMeasureNoTargets.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.GeospatialAreaPerformanceMeasureNoTargets.Add(this);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public SubbasinLiason(GeospatialArea geospatialArea, Person person) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.SubbasinLiasonID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GeospatialAreaID = geospatialArea.GeospatialAreaID;
     this.GeospatialArea   = geospatialArea;
     geospatialArea.SubbasinLiasons.Add(this);
     this.PersonID = person.PersonID;
     this.Person   = person;
     person.SubbasinLiasons.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public GeospatialAreaImage(GeospatialArea geospatialArea, FileResourceInfo fileResourceInfo) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.GeospatialAreaImageID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.GeospatialAreaID      = geospatialArea.GeospatialAreaID;
     this.GeospatialArea        = geospatialArea;
     geospatialArea.GeospatialAreaImages.Add(this);
     this.FileResourceInfoID = fileResourceInfo.FileResourceInfoID;
     this.FileResourceInfo   = fileResourceInfo;
     fileResourceInfo.GeospatialAreaImages.Add(this);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public NpccSubbasinProvince(GeospatialArea subbasin, NpccProvince npccProvince) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.NpccSubbasinProvinceID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.SubbasinID             = subbasin.GeospatialAreaID;
     this.Subbasin = subbasin;
     subbasin.NpccSubbasinProvincesWhereYouAreTheSubbasin.Add(this);
     this.NpccProvinceID = npccProvince.NpccProvinceID;
     this.NpccProvince   = npccProvince;
     npccProvince.NpccSubbasinProvinces.Add(this);
 }
Exemplo n.º 11
0
 public PerformanceMeasureChartViewData(ProjectFirmaModels.Models.GeospatialArea geospatialArea, ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, FirmaSession currentFirmaSession, bool showLastUpdatedDate, List<ProjectFirmaModels.Models.Project> projects) : this(
     performanceMeasure,
     DefaultHeight,
     currentFirmaSession,
     showLastUpdatedDate,
     false,
     projects,
     performanceMeasure.GetJavascriptSafeChartUniqueName(),
     geospatialArea)
 {
 }
        public EditPerformanceMeasureTargetsViewModel(ProjectFirmaModels.Models.GeospatialArea geospatialArea, ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
        {
            PerformanceMeasureReportingPeriodSimples = PerformanceMeasureReportingPeriodSimple.MakeFromList(performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID), performanceMeasure.PerformanceMeasureActuals);
            PerformanceMeasureTargetValueTypeID      = performanceMeasure.GetGeospatialAreaTargetValueType(geospatialArea).PerformanceMeasureTargetValueTypeID;

            if (performanceMeasure.GetGeospatialAreaTargetValueType(geospatialArea) == PerformanceMeasureTargetValueType.FixedTarget)
            {
                var fixedTarget = performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.First(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID);
                FixedTargetValue      = fixedTarget.GeospatialAreaPerformanceMeasureTargetValue;
                FixedTargetValueLabel = fixedTarget.GeospatialAreaPerformanceMeasureTargetValueLabel;
            }
        }
Exemplo n.º 13
0
        public void UpdateModel(ProjectFirmaModels.Models.GeospatialArea geospatialArea, DatabaseEntities databaseEntities)
        {
            // delete file resources for any images that are no longer referenced in the HTML
            var imagesToDelete = GeospatialAreaDescriptionContentHtmlString == null
                ? geospatialArea.GeospatialAreaImages.ToList()
                : geospatialArea.GeospatialAreaImages.Where(x => !GeospatialAreaDescriptionContentHtmlString.ToString().ContainsCaseInsensitive(x.FileResourceInfo.GetFileResourceGUIDAsString())).ToList();

            foreach (var image in imagesToDelete)
            {
                // will cascade delete the GeospatialAreaImage
                image.FileResourceInfo.DeleteFull(databaseEntities);
            }
            geospatialArea.GeospatialAreaDescriptionContentHtmlString = GeospatialAreaDescriptionContentHtmlString == null || string.IsNullOrWhiteSpace(GeospatialAreaDescriptionContentHtmlString.ToString()) ? null : GeospatialAreaDescriptionContentHtmlString;
        }
        public void DeleteOtherGeospatialAreaPerformanceMeasureTargetValueTypes(
            ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
            ProjectFirmaModels.Models.GeospatialArea geospatialArea,
            PerformanceMeasureTargetValueTypeEnum performanceMeasureTargetValueTypeEnum)
        {
            if (performanceMeasureTargetValueTypeEnum != PerformanceMeasureTargetValueTypeEnum.NoTarget)
            {
                var noTargetsToDelete = performanceMeasure.GeospatialAreaPerformanceMeasureNoTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).ToList();
                noTargetsToDelete.ForEach(oa => oa.DeleteFull(HttpRequestStorage.DatabaseEntities));
            }

            if (performanceMeasureTargetValueTypeEnum != PerformanceMeasureTargetValueTypeEnum.FixedTarget)
            {
                var overallTargetsToDelete = performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).ToList();
                overallTargetsToDelete.ForEach(oa => oa.DeleteFull(HttpRequestStorage.DatabaseEntities));
            }

            if (performanceMeasureTargetValueTypeEnum != PerformanceMeasureTargetValueTypeEnum.TargetPerYear)
            {
                var reportingPeriodTargetsToDelete = performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).ToList();
                reportingPeriodTargetsToDelete.ForEach(oa => oa.DeleteFull(HttpRequestStorage.DatabaseEntities));
            }
        }
        public void SetGoogleChartConfigurationForGeospatialAreaPerformanceMeasure(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, ProjectFirmaModels.Models.GeospatialArea geospatialArea)
        {
            // Google Chart Configuration
            if (performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Any() || performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Any())
            {
                foreach (var pfSubcategory in performanceMeasure.PerformanceMeasureSubcategories)
                {
                    var tempChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    tempChartConfig.SeriesType = "bars";
                    tempChartConfig.Series     =
                        performanceMeasure.HasGeospatialAreaTargets(geospatialArea) && performanceMeasure.HasTargets()
                            ? GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTwoTargets()
                            : GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();

                    pfSubcategory.GeospatialAreaTargetChartConfigurationJson = JObject.FromObject(tempChartConfig).ToString();
                    pfSubcategory.GeospatialAreaTargetGoogleChartTypeID      = performanceMeasure.HasGeospatialAreaTargets(geospatialArea) ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                    if (performanceMeasure.CanBeChartedCumulatively)
                    {
                        var cumulativeChartConfigurationJson = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                        cumulativeChartConfigurationJson.SeriesType    = "bars";
                        pfSubcategory.CumulativeChartConfigurationJson = JObject.FromObject(cumulativeChartConfigurationJson).ToString();
                        pfSubcategory.CumulativeGoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                    }
                }
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static GeospatialAreaImage CreateNewBlank(GeospatialArea geospatialArea, FileResourceInfo fileResourceInfo)
 {
     return(new GeospatialAreaImage(geospatialArea, fileResourceInfo));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static NpccSubbasinProvince CreateNewBlank(GeospatialArea subbasin, NpccProvince npccProvince)
 {
     return(new NpccSubbasinProvince(subbasin, npccProvince));
 }
Exemplo n.º 18
0
 public MapTooltipViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.GeospatialArea geospatialArea) : base(currentFirmaSession)
 {
     GeospatialArea           = geospatialArea;
     GeospatialAreaDetailLink = SitkaRoute <GeospatialAreaController>
                                .BuildLinkFromExpression(c => c.Detail(GeospatialArea), GeospatialArea.GeospatialAreaShortName).ToHTMLFormattedString();
 }
Exemplo n.º 19
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static SubbasinLiason CreateNewBlank(GeospatialArea geospatialArea, Person person)
 {
     return(new SubbasinLiason(geospatialArea, person));
 }
Exemplo n.º 20
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectGeospatialArea CreateNewBlank(Project project, GeospatialArea geospatialArea)
 {
     return(new ProjectGeospatialArea(project, geospatialArea));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectGeospatialAreaUpdate CreateNewBlank(ProjectUpdateBatch projectUpdateBatch, GeospatialArea geospatialArea)
 {
     return(new ProjectGeospatialAreaUpdate(projectUpdateBatch, geospatialArea));
 }
Exemplo n.º 22
0
        public static List <GoogleChartSeries> CalculateChartSeriesFromCurrentChartSeries(object currentChartSeries, ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, ProjectFirmaModels.Models.GeospatialArea geospatialArea)
        {
            // this was needed to ensure that the graphs on the geospatial detail page display appropriately for performance measure targets.
            // It attempts to be as friendly as we can to the current chart series that the user/tenant might have set
            // this is also here to catch situations where there are PM targets and Geospatial targets exists(specifically for cumulative charts on geospatial pages)
            if (currentChartSeries == null || (performanceMeasure.HasTargets() && performanceMeasure.HasGeospatialAreaTargets(geospatialArea)))
            {
                var chartSeries = new List <GoogleChartSeries>();

                //add series for the PM targets
                if (performanceMeasure.HasTargets())
                {
                    chartSeries.Add(new GoogleChartSeries(GoogleChartType.LineChart, GoogleChartAxisType.Primary));
                }
                //add another series for the Geospatial targets
                if (performanceMeasure.HasGeospatialAreaTargets(geospatialArea))
                {
                    chartSeries.Add(new GoogleChartSeries(GoogleChartType.LineChart, GoogleChartAxisType.Primary));
                }
                //add final series to have rest of the data default to bar(column)
                chartSeries.Add(new GoogleChartSeries(GoogleChartType.ColumnChart, GoogleChartAxisType.Primary));
                return(chartSeries);
            }

            var isListOfGoogleChartSeries = currentChartSeries is List <GoogleChartSeries>;
            var deserializedChartSeries   = !isListOfGoogleChartSeries?JsonConvert.DeserializeObject <List <GoogleChartSeries> >(currentChartSeries.ToString()) : (List <GoogleChartSeries>)currentChartSeries;


            return(deserializedChartSeries);
        }
Exemplo n.º 23
0
        public PerformanceMeasureTargetValueTypeEnum GetPerformanceMeasureTargetValueTypeForGeospatialArea(GeospatialArea geospatialArea)
        {
            bool hasNoTarget              = this.GeospatialAreaPerformanceMeasureNoTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID);
            bool hasFixedTarget           = this.GeospatialAreaPerformanceMeasureFixedTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID);
            bool hasReportingPeriodTarget = this.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID);

            // NOTE that the unset case (all false) is NOT yet handled! Need to think about this.
            Check.Ensure((hasNoTarget && !hasFixedTarget && !hasReportingPeriodTarget) ||
                         (!hasNoTarget && hasFixedTarget && !hasReportingPeriodTarget) ||
                         (!hasNoTarget && !hasFixedTarget && hasReportingPeriodTarget)
                         );

            if (hasNoTarget)
            {
                return(PerformanceMeasureTargetValueTypeEnum.NoTarget);
            }

            if (hasFixedTarget)
            {
                return(PerformanceMeasureTargetValueTypeEnum.FixedTarget);
            }

            if (hasReportingPeriodTarget)
            {
                return(PerformanceMeasureTargetValueTypeEnum.TargetPerYear);
            }

            throw(new NotImplementedException("Not expecting to reach here; what's the problem?"));
        }
        public void UpdateModel(ProjectFirmaModels.Models.GeospatialArea geospatialArea,
                                ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
                                ICollection <PerformanceMeasureReportingPeriod> allPerformanceMeasureReportingPeriods,
                                ICollection <GeospatialAreaPerformanceMeasureNoTarget> allGeospatialAreaPerformanceMeasureNoTargets,
                                ICollection <GeospatialAreaPerformanceMeasureFixedTarget> allGeospatialAreaPerformanceMeasureFixedTargets,
                                ICollection <GeospatialAreaPerformanceMeasureReportingPeriodTarget> allGeospatialAreaPerformanceMeasureReportingPeriodTargets)
        {
            var performanceMeasureTargetValueTypeEnum = PerformanceMeasureTargetValueType.AllLookupDictionary[PerformanceMeasureTargetValueTypeID].ToEnum;

            DeleteOtherGeospatialAreaPerformanceMeasureTargetValueTypes(performanceMeasure, geospatialArea, performanceMeasureTargetValueTypeEnum);

            switch (performanceMeasureTargetValueTypeEnum)
            {
            case PerformanceMeasureTargetValueTypeEnum.NoTarget:
                // Make a "no target" object.
                // ReSharper disable once UnusedVariable
                var noTarget = GeospatialAreaPerformanceMeasureNoTargetModelExtensions.GetOrCreateGeospatialAreaPerformanceMeasureNoTarget(performanceMeasure, geospatialArea);
                break;

            case PerformanceMeasureTargetValueTypeEnum.FixedTarget:
                var fixedTarget = performanceMeasure.GetOrCreateGeospatialAreaPerformanceMeasureFixedTarget(geospatialArea, FixedTargetValue.Value);
                fixedTarget.GeospatialAreaPerformanceMeasureTargetValueLabel = FixedTargetValueLabel;
                fixedTarget.GeospatialAreaPerformanceMeasureTargetValue      = FixedTargetValue.Value;
                break;

            case PerformanceMeasureTargetValueTypeEnum.TargetPerYear:
                var geospatialAreaPerformanceMeasureReportingPeriodTargetsUpdated =
                    new List <GeospatialAreaPerformanceMeasureReportingPeriodTarget>();
                foreach (var pmrpSimple in PerformanceMeasureReportingPeriodSimples)
                {
                    // Reporting Period
                    // ----------------
                    var reportingPeriod = allPerformanceMeasureReportingPeriods.SingleOrDefault(x => x.PerformanceMeasureReportingPeriodCalendarYear == pmrpSimple.PerformanceMeasureReportingPeriodCalendarYear);
                    if (reportingPeriod == null)
                    {
                        reportingPeriod = new PerformanceMeasureReportingPeriod(pmrpSimple.PerformanceMeasureReportingPeriodCalendarYear,
                                                                                pmrpSimple.PerformanceMeasureReportingPeriodLabel);
                    }
                    var performanceMeasureTarget = allGeospatialAreaPerformanceMeasureReportingPeriodTargets.SingleOrDefault(x => x.GeospatialAreaPerformanceMeasureReportingPeriodTargetID == pmrpSimple.GeospatialAreaPerformanceMeasureReportingPeriodTargetID);
                    if (performanceMeasureTarget == null)
                    {
                        // ReSharper disable once RedundantAssignment
                        performanceMeasureTarget = new GeospatialAreaPerformanceMeasureReportingPeriodTarget(geospatialArea, performanceMeasure, reportingPeriod)
                        {
                            GeospatialAreaPerformanceMeasureTargetValue      = pmrpSimple.TargetValue,
                            GeospatialAreaPerformanceMeasureTargetValueLabel = pmrpSimple.TargetValueLabel
                        };
                    }
                    else
                    {
                        performanceMeasureTarget.GeospatialAreaPerformanceMeasureTargetValue      = pmrpSimple.TargetValue;
                        performanceMeasureTarget.GeospatialAreaPerformanceMeasureTargetValueLabel = pmrpSimple.TargetValueLabel;
                    }
                    geospatialAreaPerformanceMeasureReportingPeriodTargetsUpdated.Add(performanceMeasureTarget);
                }

                // we need to preserve any Geospatial Area targets for geospatial areas that are not the current one we are editing.
                geospatialAreaPerformanceMeasureReportingPeriodTargetsUpdated.AddRange(allGeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID != geospatialArea.GeospatialAreaID));

                // Perform the merge, which deletes the ones that haven't been submitted
                performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Merge(geospatialAreaPerformanceMeasureReportingPeriodTargetsUpdated,
                                                                                                allGeospatialAreaPerformanceMeasureReportingPeriodTargets,
                                                                                                (x, y) => x.GeospatialAreaPerformanceMeasureReportingPeriodTargetID == y.GeospatialAreaPerformanceMeasureReportingPeriodTargetID,
                                                                                                (x, y) =>
                {
                    x.GeospatialAreaPerformanceMeasureReportingPeriodTargetID = y.GeospatialAreaPerformanceMeasureReportingPeriodTargetID;
                }, HttpRequestStorage.DatabaseEntities);

                break;

            default:
                throw new ArgumentOutOfRangeException($"Invalid Target Value Type {performanceMeasureTargetValueTypeEnum}");
            }
            SetGoogleChartConfigurationForGeospatialAreaPerformanceMeasure(performanceMeasure, geospatialArea);
        }
Exemplo n.º 25
0
 public EditGeospatialAreaDescriptionViewModel(ProjectFirmaModels.Models.GeospatialArea geospatialArea)
 {
     GeospatialAreaDescriptionContentHtmlString = geospatialArea?.GeospatialAreaDescriptionContentHtmlString;
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static GeospatialAreaPerformanceMeasureNoTarget CreateNewBlank(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure)
 {
     return(new GeospatialAreaPerformanceMeasureNoTarget(geospatialArea, performanceMeasure));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static PersonStewardGeospatialArea CreateNewBlank(Person person, GeospatialArea geospatialArea)
 {
     return(new PersonStewardGeospatialArea(person, geospatialArea));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static GeospatialAreaPerformanceMeasureReportingPeriodTarget CreateNewBlank(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure, PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod)
 {
     return(new GeospatialAreaPerformanceMeasureReportingPeriodTarget(geospatialArea, performanceMeasure, performanceMeasureReportingPeriod));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static GeospatialAreaPerformanceMeasureFixedTarget CreateNewBlank(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure)
 {
     return(new GeospatialAreaPerformanceMeasureFixedTarget(geospatialArea, performanceMeasure, default(double)));
 }