TvDatabase.TvBusinessLayer.IsChannelMappedToCard C# (CSharp) Method

IsChannelMappedToCard() public method

public IsChannelMappedToCard ( TvDatabase.Channel dbChannel, TvDatabase.Card card, bool forEpg ) : bool
dbChannel TvDatabase.Channel
card TvDatabase.Card
forEpg bool
return bool
    public bool IsChannelMappedToCard(Channel dbChannel, Card card, bool forEpg)
    {
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelMap));
      SqlStatement origStmt = sb.GetStatement(true);
      string sql = "select cm.* from ChannelMap cm where cm.idChannel =" +
                   dbChannel.IdChannel + " and cm.idCard=" + card.IdCard + (forEpg ? "" : " and cm.epgOnly=0");
      SqlStatement statement = new SqlStatement(StatementType.Select, origStmt.Command, sql,
                                                typeof (Channel));
      IList<ChannelMap> maps = ObjectFactory.GetCollection<ChannelMap>(statement.Execute());
      return maps != null && maps.Count > 0;
    }

Usage Example

    //TODO: move these helpers to other static classes

    private void SetupChannelMapping(ITvCardHandler cardHandler1, ChannelMap channelMap, TvBusinessLayer businessLayer, Channel channel)
    {
      Isolate.WhenCalled(() => channelMap.EpgOnly).WillReturn(false);
      Isolate.WhenCalled(() => channelMap.ReferencedCard().DevicePath).WillReturn(cardHandler1.DataBaseCard.DevicePath);

      TvDatabase.Card card = cardHandler1.DataBaseCard;
      Isolate.WhenCalled(() => businessLayer.IsChannelMappedToCard(channel, card, false)).WillReturn(true);      

    }
TvBusinessLayer