Example #1
0
        private static ActionResult UpdatePerformanceMeasureActuals(EditPerformanceMeasureActualsViewModel viewModel,
                                                                    List <PerformanceMeasureActual> currentPerformanceMeasureActuals,
                                                                    Project project)
        {
            HttpRequestStorage.DatabaseEntities.PerformanceMeasureActuals.Load();
            var allPerformanceMeasureActuals = HttpRequestStorage.DatabaseEntities.PerformanceMeasureActuals.Local;

            HttpRequestStorage.DatabaseEntities.PerformanceMeasureActualSubcategoryOptions.Load();
            var allPerformanceMeasureActualSubcategoryOptions = HttpRequestStorage.DatabaseEntities.PerformanceMeasureActualSubcategoryOptions.Local;

            viewModel.UpdateModel(currentPerformanceMeasureActuals, allPerformanceMeasureActuals, allPerformanceMeasureActualSubcategoryOptions, project);
            return(new ModalDialogFormJsonResult());
        }
Example #2
0
        private PartialViewResult ViewEditPerformanceMeasureActuals(Project project, EditPerformanceMeasureActualsViewModel viewModel)
        {
            var performanceMeasures = PerformanceMeasureModelExtensions.GetReportablePerformanceMeasures().ToList().SortByOrderThenName().ToList();
            var showExemptYears     = project.GetPerformanceMeasuresExemptReportingYears().Any() ||
                                      ModelState.Values.SelectMany(x => x.Errors)
                                      .Any(
                x =>
                x.ErrorMessage == FirmaValidationMessages.ExplanationNotNecessaryForProjectExemptYears ||
                x.ErrorMessage == FirmaValidationMessages.ExplanationNecessaryForProjectExemptYears);
            var viewData = new EditPerformanceMeasureActualsViewData(project, performanceMeasures, showExemptYears);

            return(RazorPartialView <EditPerformanceMeasureActuals, EditPerformanceMeasureActualsViewData, EditPerformanceMeasureActualsViewModel>(viewData, viewModel));
        }
Example #3
0
        public PartialViewResult EditPerformanceMeasureActualsForProject(ProjectPrimaryKey projectPrimaryKey)
        {
            var project = projectPrimaryKey.EntityObject;
            var performanceMeasureActualSimples = project.PerformanceMeasureActuals.OrderBy(pam => pam.PerformanceMeasure.SortOrder).ThenBy(pam => pam.PerformanceMeasure.DisplayName).Select(x => new PerformanceMeasureActualSimple(x)).ToList();
            var projectExemptReportingYears     = project.GetPerformanceMeasuresExemptReportingYears().Select(x => new ProjectExemptReportingYearSimple(x)).ToList();
            var currentExemptedYears            = projectExemptReportingYears.Select(x => x.CalendarYear).ToList();
            var endYear               = DateTime.Now.Year;
            var startYear             = project.GetImplementationStartYear() ?? endYear;
            var possibleYearsToExempt = FirmaDateUtilities.GetRangeOfYears(startYear, endYear).OrderBy(x => x).ToList();

            projectExemptReportingYears.AddRange(
                possibleYearsToExempt.Where(x => !currentExemptedYears.Contains(x)).Select((x, index) => new ProjectExemptReportingYearSimple(-(index + 1), project.ProjectID, x)));

            var viewModel = new EditPerformanceMeasureActualsViewModel(performanceMeasureActualSimples,
                                                                       project.PerformanceMeasureActualYearsExemptionExplanation,
                                                                       projectExemptReportingYears.OrderBy(x => x.CalendarYear).ToList());

            return(ViewEditPerformanceMeasureActuals(project, viewModel));
        }
Example #4
0
        public ActionResult EditPerformanceMeasureActualsForProject(ProjectPrimaryKey projectPrimaryKey, EditPerformanceMeasureActualsViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditPerformanceMeasureActuals(project, viewModel));
            }
            var currentPerformanceMeasureActuals = project.PerformanceMeasureActuals.ToList();

            return(UpdatePerformanceMeasureActuals(viewModel, currentPerformanceMeasureActuals, project));
        }