2012-09-07 16:17:39 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-09-11 01:34:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2012-08-17 13:16:50 +00:00
|
|
|
|
using MediaBrowser.Model.DTO;
|
2012-09-08 14:52:13 +00:00
|
|
|
|
using System.ComponentModel.Composition;
|
|
|
|
|
using System.Net;
|
2012-09-07 16:17:39 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
2012-09-09 18:32:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides a handler to retrieve a single item
|
|
|
|
|
/// </summary>
|
2012-09-08 14:52:13 +00:00
|
|
|
|
[Export(typeof(BaseHandler))]
|
2012-09-11 18:20:12 +00:00
|
|
|
|
public class ItemHandler : BaseSerializationHandler<DtoBaseItem>
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
public override bool HandlesRequest(HttpListenerRequest request)
|
|
|
|
|
{
|
|
|
|
|
return ApiService.IsApiUrlMatch("item", request);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-11 18:20:12 +00:00
|
|
|
|
protected override Task<DtoBaseItem> GetObjectToSerialize()
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-09-07 16:17:39 +00:00
|
|
|
|
User user = ApiService.GetUserById(QueryString["userid"], true);
|
2012-08-15 13:20:29 +00:00
|
|
|
|
|
2012-09-09 18:32:51 +00:00
|
|
|
|
BaseItem item = ApiService.GetItemById(QueryString["id"]);
|
2012-07-16 16:50:44 +00:00
|
|
|
|
|
2012-08-15 13:20:29 +00:00
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
2012-08-15 13:20:29 +00:00
|
|
|
|
|
2012-09-11 18:20:12 +00:00
|
|
|
|
return ApiService.GetDtoBaseItem(item, user);
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|