public ActionResult EditPerformanceMeasureReportedValues(
            PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey)
        {
            var performanceMeasure = performanceMeasurePrimaryKey.EntityObject;
            var viewModel          = new EditPerformanceMeasureTargetsViewModel(performanceMeasure);

            return(ViewEditPerformanceMeasureReportedValues(performanceMeasure, viewModel));
        }
        private ActionResult ViewEditPerformanceMeasureReportedValues(PerformanceMeasure performanceMeasure,
                                                                      EditPerformanceMeasureTargetsViewModel viewModel)
        {
            var performanceMeasureTargetValueTypes = PerformanceMeasureTargetValueType.All.ToList();
            var reportingPeriods           = performanceMeasure.GetPerformanceMeasureReportingPeriodsFromTargetsAndActuals();
            var defaultReportingPeriodYear = reportingPeriods.Any()
                ? reportingPeriods.Max(x => x.PerformanceMeasureReportingPeriodCalendarYear) + 1
                : DateTime.Now.Year;
            var viewDataForAngular = new EditPerformanceMeasureTargetsViewDataForAngular(performanceMeasure,
                                                                                         defaultReportingPeriodYear,
                                                                                         performanceMeasureTargetValueTypes,
                                                                                         false);
            var viewData = new EditPerformanceMeasureTargetsViewData(performanceMeasure, viewDataForAngular,
                                                                     EditPerformanceMeasureTargetsViewData.PerformanceMeasureTargetType.TargetByYear);

            return(RazorPartialView <EditPerformanceMeasureTargets, EditPerformanceMeasureTargetsViewData,
                                     EditPerformanceMeasureTargetsViewModel>(viewData, viewModel));
        }
        public ActionResult EditPerformanceMeasureReportedValues(
            PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey, EditPerformanceMeasureTargetsViewModel viewModel)
        {
            var performanceMeasure = performanceMeasurePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditPerformanceMeasureReportedValues(performanceMeasure, viewModel));
            }

            HttpRequestStorage.DatabaseEntities.PerformanceMeasureReportingPeriodTargets.Load();
            HttpRequestStorage.DatabaseEntities.PerformanceMeasureReportingPeriods.Load();
            viewModel.UpdateModel(performanceMeasure,
                                  HttpRequestStorage.DatabaseEntities.AllPerformanceMeasureReportingPeriods.Local,
                                  HttpRequestStorage.DatabaseEntities.AllPerformanceMeasureReportingPeriodTargets.Local);

            SetMessageForDisplay(
                $"Successfully saved {FieldDefinitionEnum.PerformanceMeasure.ToType().GetFieldDefinitionLabel()} Targets");
            return(new ModalDialogFormJsonResult());
        }