/// <summary> Clears the internal data for this code manager </summary> public void Clear() { Aggregations_By_Thematic_Heading.Clear(); aggregationsByType.Clear(); aggregationsByCode.Clear(); allTypes.Clear(); All_Aggregations.Clear(); }
/// <summary> Add the basic information about an aggregation to this aggreation manager </summary> /// <param name="New_Aggregation"> New aggregation to add information about </param> public void Add_Collection(Item_Aggregation_Related_Aggregations New_Aggregation) { // Insert this into the proper spot in the item aggregation list int index = 0; while ((index < All_Aggregations.Count) && (string.CompareOrdinal(New_Aggregation.Code, All_Aggregations[index].Code) > 0)) { index++; } All_Aggregations.Insert(index, New_Aggregation); // Add this to the various dictionaries aggregationsByCode[New_Aggregation.Code] = New_Aggregation; if (!allTypes.Contains(New_Aggregation.Type)) { allTypes.Add(New_Aggregation.Type); } if (aggregationsByType.ContainsKey(New_Aggregation.Type)) { aggregationsByType[New_Aggregation.Type].Add(New_Aggregation); } else { aggregationsByType[New_Aggregation.Type] = new List <Item_Aggregation_Related_Aggregations> { New_Aggregation }; } if ((New_Aggregation.Thematic_Heading != null) && (New_Aggregation.Thematic_Heading.ID > 0)) { if (Aggregations_By_Thematic_Heading.ContainsKey(New_Aggregation.Thematic_Heading.ID)) { Aggregations_By_Thematic_Heading[New_Aggregation.Thematic_Heading.ID].Add(New_Aggregation); } else { Aggregations_By_Thematic_Heading[New_Aggregation.Thematic_Heading.ID] = new List <Item_Aggregation_Related_Aggregations> { New_Aggregation }; } } }
/// <summary> Gets the aggregation by primary key </summary> /// <param name="AggregationID"> Aggregation ID for the aggregation to get </param> /// <returns> Either the match, or NULL </returns> /// <remarks> This is not particularly a quick way to do this, since it just loops through all the aggregations, without /// utilizing a dictionary for lookup. </remarks> public Item_Aggregation_Related_Aggregations Aggregation_By_ID(int AggregationID) { return(All_Aggregations.FirstOrDefault(ThisAggr => ThisAggr.ID == AggregationID)); }