TvDatabase.TvBusinessLayer.AddChannelToRadioGroup C# (CSharp) Method

AddChannelToRadioGroup() public method

Add a radio channel to radio group by name
public AddChannelToRadioGroup ( TvDatabase.Channel channel, string groupName ) : void
channel TvDatabase.Channel channel to add
groupName string target group name
return void
    public void AddChannelToRadioGroup(Channel channel, string groupName)
    {
      RadioChannelGroup currentRadioGroup = null;
      IList<RadioChannelGroup> allRadioGroups = RadioChannelGroup.ListAll();

      // check for existing group
      foreach (RadioChannelGroup radioGroup in allRadioGroups)
      {
        if (radioGroup.GroupName == groupName)
        {
          currentRadioGroup = radioGroup;
          break;
        }
      }
      // no group found yet? then create new one
      if (currentRadioGroup == null)
      {
        currentRadioGroup = new RadioChannelGroup(groupName, allRadioGroups.Count);
        currentRadioGroup.Persist();
      }
      // add channel to group
      AddChannelToRadioGroup(channel, currentRadioGroup);
    }

Same methods

TvBusinessLayer::AddChannelToRadioGroup ( TvDatabase.Channel channel, TvDatabase.RadioChannelGroup group ) : void

Usage Example

    private void AddSelectedItemsToGroup(MPListView sourceListView)
    {
      if (_channelGroup == null)
      {
        return;
      }

      TvBusinessLayer layer = new TvBusinessLayer();
      foreach (ListViewItem sourceItem in sourceListView.SelectedItems)
      {
        Channel channel = null;
        if (sourceItem.Tag is Channel)
        {
          channel = (Channel)sourceItem.Tag;
        }
        else if (sourceItem.Tag is RadioGroupMap)
        {
          channel = layer.GetChannel(((RadioGroupMap)sourceItem.Tag).IdChannel);
        }
        else
        {
          continue;
        }

        RadioGroupMap groupMap = null;

        layer.AddChannelToRadioGroup(channel, _channelGroup);

        //get the new group map and set the listitem tag
        SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (RadioGroupMap));

        sb.AddConstraint(Operator.Equals, "idChannel", channel.IdChannel);
        sb.AddConstraint(Operator.Equals, "idGroup", _channelGroup.IdGroup);

        SqlStatement stmt = sb.GetStatement(true);

        groupMap = ObjectFactory.GetInstance<RadioGroupMap>(stmt.Execute());

        foreach (ListViewItem item in listView1.Items)
        {
          if ((item.Tag as Channel) == channel)
          {
            item.Tag = groupMap;
            break;
          }
        }
      }
    }
All Usage Examples Of TvDatabase.TvBusinessLayer::AddChannelToRadioGroup
TvBusinessLayer