/// <summary> Adds a new blank thematic heading when a user adds one through /// the administrative tools </summary> /// <param name="NewThematicHeadingID">ID for the new thematic heading</param> public void Add_Blank_Thematic_Heading(int NewThematicHeadingID) { if (!Aggregations_By_Thematic_Heading.ContainsKey(NewThematicHeadingID)) { Aggregations_By_Thematic_Heading[NewThematicHeadingID] = new List <Item_Aggregation_Related_Aggregations>(); } }
/// <summary> /// Read-only collection of item aggregationPermissions matching a particular thematic heading id /// </summary> /// <param name = "ThemeID"> Primary key for the thematic heading to pull </param> /// <returns> Read-only collection of item aggregation relational objects </returns> public ReadOnlyCollection <Item_Aggregation_Related_Aggregations> Aggregations_By_ThemeID(int ThemeID) { if (Aggregations_By_Thematic_Heading.ContainsKey(ThemeID)) { return(new ReadOnlyCollection <Item_Aggregation_Related_Aggregations>(Aggregations_By_Thematic_Heading[ThemeID])); } return(new ReadOnlyCollection <Item_Aggregation_Related_Aggregations>(new List <Item_Aggregation_Related_Aggregations>())); }
/// <summary> Set an aggregation to be a part of an existing thematic heading id </summary> /// <param name="Code"></param> /// <param name="ThematicHeadingID"></param> public void Set_Aggregation_Thematic_Heading(string Code, int?ThematicHeadingID) { Item_Aggregation_Related_Aggregations thisAggr = aggregationsByCode[Code.ToUpper()]; // If this is NULL, just return if ((!ThematicHeadingID.HasValue) || (ThematicHeadingID.Value < 0)) { foreach (KeyValuePair <int, List <Item_Aggregation_Related_Aggregations> > theme in Aggregations_By_Thematic_Heading) { if (theme.Value.Contains(thisAggr)) { theme.Value.Remove(thisAggr); } } return; } // If the thematic heading ID does not exit, just return if (!Aggregations_By_Thematic_Heading.ContainsKey(ThematicHeadingID.Value)) { return; } // If this aggregation does not exist, just return if (!aggregationsByCode.ContainsKey(Code.ToUpper())) { return; } // Get this aggregation and list for this thematic heading List <Item_Aggregation_Related_Aggregations> thematicHeadingList = Aggregations_By_Thematic_Heading[ThematicHeadingID.Value]; // If this is already a part of the thematic heading, just return if (thematicHeadingList.Contains(thisAggr)) { return; } // Ensure this aggregation is not a part of any other thematic headings foreach (KeyValuePair <int, List <Item_Aggregation_Related_Aggregations> > theme in Aggregations_By_Thematic_Heading) { if (theme.Value.Contains(thisAggr)) { theme.Value.Remove(thisAggr); } } // Now, add this to the list for this thematic heading int index = 0; while ((index < thematicHeadingList.Count) && (string.CompareOrdinal(thisAggr.Code, thematicHeadingList[index].Code) > 0)) { index++; } thematicHeadingList.Insert(index, thisAggr); }
/// <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 }; } } }