/// <summary> /// Get a list of ChannelGroup referring to the current entity. /// </summary> public IList <GroupMap> ReferringChannelGroup() { SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(KeywordMap)); sb.AddConstraint(Operator.Equals, "idKeyword", idKeyword); sb.AddOrderByField("SortOrder"); SqlStatement stmt = sb.GetStatement(true); List <GroupMap> returnList = new List <GroupMap>(); IList <KeywordMap> list = ObjectFactory.GetCollection <KeywordMap>(stmt.Execute()); foreach (KeywordMap map in list) { ChannelGroup group = map.ReferencedChannelGroup(); returnList.InsertRange(0, group.ReferringGroupMap()); } return(returnList); }
public void AddChannelToGroup(Channel channel, ChannelGroup group) { bool found = false; IList<GroupMap> groupMaps = group.ReferringGroupMap(); foreach (GroupMap map in groupMaps) { if (map.IdChannel == channel.IdChannel) { found = true; break; } } if (!found) { GroupMap map = new GroupMap(group.IdGroup, channel.IdChannel, channel.SortOrder); map.Persist(); } }