Example #1
0
        public List <PerformanceMeasureReportedValue> GetNonVirtualPerformanceMeasureReportedValues()
        {
            var performanceMeasureReportedValues = PerformanceMeasureActuals.Select(x => x.PerformanceMeasure)
                                                   .Distinct(new HavePrimaryKeyComparer <PerformanceMeasure>())
                                                   .SelectMany(x => x.GetReportedPerformanceMeasureValues(this)).ToList();

            return(performanceMeasureReportedValues.OrderByDescending(pma => pma.CalendarYear)
                   .ThenBy(pma => pma.PerformanceMeasureID).ToList());
        }
        private HashSet <int> ValidateNoIncompletePerformanceMeasureActualRow()
        {
            if (PerformanceMeasureActuals == null)
            {
                return(new HashSet <int>());
            }
            var performanceMeasureIDs =
                PerformanceMeasureActuals.Select(x => x.PerformanceMeasureID.GetValueOrDefault()).Distinct();
            var performanceMeasuresIDsAndSubcategoryCounts =
                HttpRequestStorage.DatabaseEntities.PerformanceMeasures.Where(x =>
                                                                              performanceMeasureIDs.Contains(x.PerformanceMeasureID)).Select(x => new { x.PerformanceMeasureID, SubcategoryCount = x.PerformanceMeasureSubcategories.Count });

            var performanceMeasureActualsWithMissingSubcategoryOptions =
                PerformanceMeasureActuals.Where(
                    x => !x.ActualValue.HasValue || performanceMeasuresIDsAndSubcategoryCounts.Single(y => x.PerformanceMeasureID == y.PerformanceMeasureID).SubcategoryCount != x.PerformanceMeasureActualSubcategoryOptions.Count || x.PerformanceMeasureActualSubcategoryOptions.Any(y => y.PerformanceMeasureSubcategoryOptionID == null)).ToList();

            return(new HashSet <int>(performanceMeasureActualsWithMissingSubcategoryOptions.Select(x => x.PerformanceMeasureActualID.GetValueOrDefault())));
        }
Example #3
0
 public List <Project> GetAssociatedProjectsWithReportedValues(Person currentPerson)
 {
     return(PerformanceMeasureActuals.Select(ptc => ptc.Project).ToList().GetActiveProjectsAndProposalsVisibleToUser(currentPerson));
 }
        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;
        }