2014-03-18 01:45:41 +00:00
|
|
|
|
using MediaBrowser.Controller.Channels;
|
|
|
|
|
using MediaBrowser.Model.Channels;
|
|
|
|
|
using MediaBrowser.Model.Dto;
|
|
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
|
using ServiceStack;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api
|
|
|
|
|
{
|
2014-03-26 16:10:46 +00:00
|
|
|
|
[Route("/Channels", "GET", Summary = "Gets available channels")]
|
2014-03-18 01:45:41 +00:00
|
|
|
|
public class GetChannels : IReturn<QueryResult<BaseItemDto>>
|
|
|
|
|
{
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
public int? StartIndex { get; set; }
|
|
|
|
|
|
|
|
|
|
public int? Limit { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-26 16:10:46 +00:00
|
|
|
|
[Route("/Channels/{Id}/Items", "GET", Summary = "Gets channel items")]
|
2014-03-18 17:05:57 +00:00
|
|
|
|
public class GetChannelItems : IReturn<QueryResult<BaseItemDto>>
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public string CategoryId { get; set; }
|
|
|
|
|
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
public int? StartIndex { get; set; }
|
|
|
|
|
|
|
|
|
|
public int? Limit { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-18 01:45:41 +00:00
|
|
|
|
public class ChannelService : BaseApiService
|
|
|
|
|
{
|
|
|
|
|
private readonly IChannelManager _channelManager;
|
|
|
|
|
|
|
|
|
|
public ChannelService(IChannelManager channelManager)
|
|
|
|
|
{
|
|
|
|
|
_channelManager = channelManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Get(GetChannels request)
|
|
|
|
|
{
|
|
|
|
|
var result = _channelManager.GetChannels(new ChannelQuery
|
|
|
|
|
{
|
|
|
|
|
Limit = request.Limit,
|
|
|
|
|
StartIndex = request.StartIndex,
|
|
|
|
|
UserId = request.UserId,
|
|
|
|
|
|
|
|
|
|
}, CancellationToken.None).Result;
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
2014-03-18 17:05:57 +00:00
|
|
|
|
|
|
|
|
|
public object Get(GetChannelItems request)
|
|
|
|
|
{
|
|
|
|
|
var result = _channelManager.GetChannelItems(new ChannelItemQuery
|
|
|
|
|
{
|
|
|
|
|
Limit = request.Limit,
|
|
|
|
|
StartIndex = request.StartIndex,
|
|
|
|
|
UserId = request.UserId,
|
|
|
|
|
ChannelId = request.Id,
|
|
|
|
|
CategoryId = request.CategoryId
|
|
|
|
|
|
|
|
|
|
}, CancellationToken.None).Result;
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
2014-03-18 01:45:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|