public void UpdateModel(List <Models.PerformanceMeasureActual> currentPerformanceMeasureActuals, IList <Models.PerformanceMeasureActual> allPerformanceMeasureActuals, IList <PerformanceMeasureActualSubcategoryOption> allPerformanceMeasureActualSubcategoryOptions, Models.Project project) { UpdateModelImpl(currentPerformanceMeasureActuals, allPerformanceMeasureActuals, allPerformanceMeasureActualSubcategoryOptions); var currentProjectExemptYears = project.GetPerformanceMeasuresExemptReportingYears(); HttpRequestStorage.DatabaseEntities.ProjectExemptReportingYears.Load(); var allProjectExemptYears = HttpRequestStorage.DatabaseEntities.ProjectExemptReportingYears.Local; var projectExemptReportingYears = new List <ProjectExemptReportingYear>(); if (ProjectExemptReportingYears != null) { // Completely rebuild the list projectExemptReportingYears = ProjectExemptReportingYears.Where(x => x.IsExempt).Select(x => new ProjectExemptReportingYear(x.ProjectID, x.CalendarYear, ProjectExemptReportingType.PerformanceMeasures.ProjectExemptReportingTypeID)).ToList(); } currentProjectExemptYears.Merge(projectExemptReportingYears, allProjectExemptYears, (x, y) => x.ProjectID == y.ProjectID && x.CalendarYear == y.CalendarYear && x.ProjectExemptReportingTypeID == y.ProjectExemptReportingTypeID); project.PerformanceMeasureActualYearsExemptionExplanation = Explanation; }
public void UpdateModel(List <Models.PerformanceMeasureActual> currentPerformanceMeasureActuals, IList <Models.PerformanceMeasureActual> allPerformanceMeasureActuals, IList <PerformanceMeasureActualSubcategoryOption> allPerformanceMeasureActualSubcategoryOptions, Models.Project project) { var currentPerformanceMeasureActualSubcategoryOptions = currentPerformanceMeasureActuals.SelectMany(x => x.PerformanceMeasureActualSubcategoryOptions).ToList(); var performanceMeasureActualsUpdated = new List <Models.PerformanceMeasureActual>(); if (PerformanceMeasureActuals != null) { // Completely rebuild the list performanceMeasureActualsUpdated = PerformanceMeasureActuals.Select(x => { var performanceMeasureActual = new Models.PerformanceMeasureActual(x.PerformanceMeasureActualID.GetValueOrDefault(), x.ProjectID.GetValueOrDefault(), x.PerformanceMeasureID.GetValueOrDefault(), x.CalendarYear.GetValueOrDefault(), x.ActualValue.GetValueOrDefault()); if (x.PerformanceMeasureActualSubcategoryOptions != null) { performanceMeasureActual.PerformanceMeasureActualSubcategoryOptions = x.PerformanceMeasureActualSubcategoryOptions.Where(pmavsou => ModelObjectHelpers.IsRealPrimaryKeyValue(pmavsou.PerformanceMeasureSubcategoryOptionID)) .Select( y => new PerformanceMeasureActualSubcategoryOption(performanceMeasureActual.PerformanceMeasureActualID, y.PerformanceMeasureSubcategoryOptionID.GetValueOrDefault(), y.PerformanceMeasureID, y.PerformanceMeasureSubcategoryID)) .ToList(); } return(performanceMeasureActual); }).ToList(); } currentPerformanceMeasureActuals.Merge(performanceMeasureActualsUpdated, allPerformanceMeasureActuals, (x, y) => x.PerformanceMeasureActualID == y.PerformanceMeasureActualID, (x, y) => { x.CalendarYear = y.CalendarYear; x.ActualValue = y.ActualValue; }); currentPerformanceMeasureActualSubcategoryOptions.Merge( performanceMeasureActualsUpdated.SelectMany(x => x.PerformanceMeasureActualSubcategoryOptions).ToList(), allPerformanceMeasureActualSubcategoryOptions, (x, y) => x.PerformanceMeasureActualID == y.PerformanceMeasureActualID && x.PerformanceMeasureSubcategoryID == y.PerformanceMeasureSubcategoryID && x.PerformanceMeasureID == y.PerformanceMeasureID, (x, y) => x.PerformanceMeasureSubcategoryOptionID = y.PerformanceMeasureSubcategoryOptionID); var currentProjectExemptYears = project.GetPerformanceMeasuresExemptReportingYears(); HttpRequestStorage.DatabaseEntities.ProjectExemptReportingYears.Load(); var allProjectExemptYears = HttpRequestStorage.DatabaseEntities.ProjectExemptReportingYears.Local; var projectExemptReportingYears = new List <ProjectExemptReportingYear>(); if (ProjectExemptReportingYears != null) { // Completely rebuild the list projectExemptReportingYears = ProjectExemptReportingYears.Where(x => x.IsExempt) .Select(x => new ProjectExemptReportingYear(x.ProjectExemptReportingYearID, x.ProjectID, x.CalendarYear, ProjectExemptReportingType.PerformanceMeasures.ProjectExemptReportingTypeID)) .ToList(); } currentProjectExemptYears.Merge(projectExemptReportingYears, allProjectExemptYears, (x, y) => x.ProjectID == y.ProjectID && x.CalendarYear == y.CalendarYear && x.ProjectExemptReportingTypeID == y.ProjectExemptReportingTypeID); project.PerformanceMeasureActualYearsExemptionExplanation = Explanation; }
public PerformanceMeasuresViewData(Person currentPerson, Models.Project project, ViewDataForAngularEditor viewDataForAngularEditor, ProposalSectionsStatus proposalSectionsStatus) : base(currentPerson, project, ProjectCreateSection.ReportedPerformanceMeasures.ProjectCreateSectionDisplayName, proposalSectionsStatus) { RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshPerformanceMeasures(project)); DiffUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.DiffPerformanceMeasures(project)); var performanceMeasureActuals = project.GetReportedPerformanceMeasures(); var performanceMeasureSubcategoriesCalendarYearReportedValues = PerformanceMeasureSubcategoriesCalendarYearReportedValue.CreateFromPerformanceMeasuresAndCalendarYears(new List <IPerformanceMeasureReportedValue>(performanceMeasureActuals)); PerformanceMeasureReportedValuesSummaryViewData = new PerformanceMeasureReportedValuesSummaryViewData(performanceMeasureSubcategoriesCalendarYearReportedValues, project.GetPerformanceMeasuresExemptReportingYears().Select(x => x.CalendarYear).ToList(), project.PerformanceMeasureActualYearsExemptionExplanation, performanceMeasureActuals.Select(x => x.CalendarYear).Distinct().Select(x => new CalendarYearString(x)).ToList()); ViewDataForAngular = viewDataForAngularEditor; IsImplementationStartYearValid = project.GetImplementationStartYear().HasValue&& project.GetImplementationStartYear() < project.GetCompletionYear(); ReportingYearLabel = "Year"; }