public static async Task <IList <WebChannelState> > ProcessAsync(IOwinContext context, string groupId, string userName) { List <WebChannelState> output = new List <WebChannelState>(); if (groupId == null) { throw new BadRequestException("GetAllRadioChannelStatesForGroup: groupId is null"); } if (userName == null) { throw new BadRequestException("GetAllRadioChannelStatesForGroup: userName is null"); } if (!ServiceRegistration.IsRegistered <ITvProvider>()) { throw new BadRequestException("GetAllRadioChannelStatesForGroup: ITvProvider not found"); } var channels = await TVAccess.GetGroupChannelsAsync(context, groupId != null?int.Parse(groupId) : (int?)null); output.AddRange(channels.Where(x => x.MediaType == MediaType.Radio).Select(channel => new WebChannelState { ChannelId = channel.ChannelId, State = ChannelState.Tunable, // TODO: implement in SlimTv })); return(output); }
public static async Task <WebIntResult> ProcessAsync(IOwinContext context, string groupId = null) { if (!ServiceRegistration.IsRegistered <ITvProvider>()) { throw new BadRequestException("GetRadioChannelCount: ITvProvider not found"); } var channels = await TVAccess.GetGroupChannelsAsync(context, groupId != null?int.Parse(groupId) : (int?)null); return(new WebIntResult { Result = channels.Where(c => c.MediaType == MediaType.Radio).Count() }); }
public static async Task <IList <WebChannelDetailed> > ProcessAsync(IOwinContext context, string groupId, WebSortField?sort, WebSortOrder?order) { if (!ServiceRegistration.IsRegistered <ITvProvider>()) { throw new BadRequestException("GetChannelsDetailed: ITvProvider not found"); } List <WebChannelDetailed> output = new List <WebChannelDetailed>(); var channels = await TVAccess.GetGroupChannelsAsync(context, groupId != null?int.Parse(groupId) : (int?)null); output.AddRange(channels.Where(x => x.MediaType == MediaType.TV).Select(channel => ChannelDetailed(channel))); // sort if (sort != null && order != null) { output = output.SortChannelList(sort, order).ToList(); } return(output); }
public static async Task <IList <WebChannelBasic> > ProcessAsync(IOwinContext context, int start, int end, string groupId, WebSortField?sort, WebSortOrder?order) { List <WebChannelBasic> output = new List <WebChannelBasic>(); if (!ServiceRegistration.IsRegistered <ITvProvider>()) { throw new BadRequestException("GetRadioChannelsBasicByRange: ITvProvider not found"); } var channels = await TVAccess.GetGroupChannelsAsync(context, groupId != null?int.Parse(groupId) : (int?)null); output.AddRange(channels.Where(x => x.MediaType == MediaType.Radio).Select(channel => ChannelBasic(channel))); // sort if (sort != null && order != null) { output = output.SortChannelList(sort, order).ToList(); } // get range output = output.TakeRange(start, end).ToList(); return(output); }