public static List <ProjectRelevantCostTypeUpdate> GetRelevantCostTypesByCostTypeGroup(this ProjectUpdateBatch projectUpdateBatch, ProjectRelevantCostTypeGroup projectRelevantCostTypeGroup) { return(projectUpdateBatch.ProjectRelevantCostTypeUpdates .Where(x => x.ProjectRelevantCostTypeGroup == projectRelevantCostTypeGroup) .OrderBy(x => x.CostType.CostTypeName).ToList()); }
public static List <ProjectRelevantCostTypeSimple> GetAllProjectRelevantCostTypesAsSimples(this ProjectUpdateBatch projectUpdateBatch, ProjectRelevantCostTypeGroup projectRelevantCostTypeGroup) { var costTypes = HttpRequestStorage.DatabaseEntities.CostTypes.ToList(); var projectRelevantCostTypes = projectUpdateBatch.GetRelevantCostTypesByCostTypeGroup(projectRelevantCostTypeGroup).Select(x => new ProjectRelevantCostTypeSimple(x)).ToList(); var currentRelevantCostTypeIDs = projectRelevantCostTypes.Select(x => x.CostTypeID).ToList(); projectRelevantCostTypes.AddRange( costTypes.Where(x => !currentRelevantCostTypeIDs.Contains(x.CostTypeID)) .Select((x, index) => new ProjectRelevantCostTypeSimple(-(index + 1), projectUpdateBatch.ProjectID, x.CostTypeID, x.CostTypeName))); return(projectRelevantCostTypes); }