/// <summary> /// Only public for unit testing /// </summary> public static PerformanceMeasureExpectedUpdate ClonePerformanceMeasureValue(ProjectUpdateBatch projectUpdateBatch, IPerformanceMeasureValue performanceMeasureValueToClone, double?expectedValue) { var performanceMeasureExpectedUpdate = new PerformanceMeasureExpectedUpdate(projectUpdateBatch, performanceMeasureValueToClone.PerformanceMeasure) { ExpectedValue = expectedValue }; performanceMeasureExpectedUpdate.PerformanceMeasureExpectedSubcategoryOptionUpdates = performanceMeasureValueToClone.GetPerformanceMeasureSubcategoryOptions().Select( performanceMeasureExpectedSubcategoryOption => new PerformanceMeasureExpectedSubcategoryOptionUpdate(performanceMeasureExpectedUpdate, performanceMeasureExpectedSubcategoryOption.PerformanceMeasureSubcategoryOption, performanceMeasureExpectedSubcategoryOption.PerformanceMeasure, performanceMeasureExpectedSubcategoryOption.PerformanceMeasureSubcategory)).ToList(); return(performanceMeasureExpectedUpdate); }
/// <summary> /// Only public for unit testing /// </summary> public static PerformanceMeasureActualUpdate ClonePerformanceMeasureValue(ProjectUpdateBatch projectUpdateBatch, IPerformanceMeasureValue performanceMeasureValueToClone, int newCalendarYear, double?actualValue) { var performanceMeasureActualUpdate = new PerformanceMeasureActualUpdate(projectUpdateBatch, performanceMeasureValueToClone.PerformanceMeasure, newCalendarYear) { ActualValue = actualValue }; performanceMeasureActualUpdate.PerformanceMeasureActualSubcategoryOptionUpdates = performanceMeasureValueToClone.PerformanceMeasureSubcategoryOptions.Select( performanceMeasureActualSubcategoryOption => new PerformanceMeasureActualSubcategoryOptionUpdate(performanceMeasureActualUpdate, performanceMeasureActualSubcategoryOption.PerformanceMeasureSubcategoryOption, performanceMeasureActualSubcategoryOption.PerformanceMeasure, performanceMeasureActualSubcategoryOption.PerformanceMeasureSubcategory)).ToList(); return(performanceMeasureActualUpdate); }
/// <summary> /// Only public for unit testing /// </summary> public static PerformanceMeasureActualUpdate ClonePerformanceMeasureValue(ProjectUpdateBatch projectUpdateBatch, IPerformanceMeasureValue performanceMeasureValueToClone, int newCalendarYear, double?actualValue) { var performanceMeasureReportingPeriod = HttpRequestStorage.DatabaseEntities.PerformanceMeasureReportingPeriods.GetOrCreatePerformanceMeasureReportingPeriod(newCalendarYear); Check.EnsureNotNull(performanceMeasureReportingPeriod, "We need to have a performance measure reporting period here"); var performanceMeasureActualUpdate = new PerformanceMeasureActualUpdate(projectUpdateBatch, performanceMeasureValueToClone.PerformanceMeasure, performanceMeasureReportingPeriod) { ActualValue = actualValue }; performanceMeasureActualUpdate.PerformanceMeasureActualSubcategoryOptionUpdates = performanceMeasureValueToClone.GetPerformanceMeasureSubcategoryOptions().Select( performanceMeasureActualSubcategoryOption => new PerformanceMeasureActualSubcategoryOptionUpdate(performanceMeasureActualUpdate, performanceMeasureActualSubcategoryOption.PerformanceMeasureSubcategoryOption, performanceMeasureActualSubcategoryOption.PerformanceMeasure, performanceMeasureActualSubcategoryOption.PerformanceMeasureSubcategory)).ToList(); return(performanceMeasureActualUpdate); }
public static IEnumerable <PerformanceMeasureValueSubcategoryOption> GetAllPossibleSubcategoryOptionsForPerformanceMeasureValue(IPerformanceMeasureValue performanceMeasureValue) { var performanceMeasure = performanceMeasureValue.PerformanceMeasure; var selectedPerformanceMeasureValueSubcategoryOptions = performanceMeasureValue.GetPerformanceMeasureSubcategoryOptions(); // we need to get all possible subcategories for this performance measure and default it with empty values // we do this to prime the angular editor to have these performanceMeasureSubcategory dropdowns there, even if they didn't choose an option for that performanceMeasureSubcategory // since this part is optional when creating an expected value record var allPossiblePerformanceMeasureActualUpdateSubcategoryOptions = performanceMeasure.PerformanceMeasureSubcategories.Select( x => new PerformanceMeasureValueSubcategoryOption(ModelObjectHelpers.NotYetAssignedID, ModelObjectHelpers.NotYetAssignedID, x.PerformanceMeasure, x)).ToList(); var subcategoryOptionUpdateSimplesSelected = selectedPerformanceMeasureValueSubcategoryOptions.Select( x => new PerformanceMeasureValueSubcategoryOption(x.PrimaryKey, x.PerformanceMeasureSubcategoryOption?.PerformanceMeasureSubcategoryOptionID ?? ModelObjectHelpers.NotYetAssignedID, x.PerformanceMeasure, x.PerformanceMeasureSubcategory)).ToList(); allPossiblePerformanceMeasureActualUpdateSubcategoryOptions.MergeUpdate(subcategoryOptionUpdateSimplesSelected, (x, y) => x.PerformanceMeasureSubcategory.PerformanceMeasureSubcategoryID == y.PerformanceMeasureSubcategory.PerformanceMeasureSubcategoryID, (x, y) => x.PerformanceMeasureSubcategoryOptionID = y.PerformanceMeasureSubcategoryOptionID); return(allPossiblePerformanceMeasureActualUpdateSubcategoryOptions); }