2012-07-16 16:50:44 +00:00
|
|
|
|
using System;
|
2012-08-18 08:22:54 +00:00
|
|
|
|
using System.Linq;
|
2012-08-19 20:38:31 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2012-08-15 13:20:29 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-08-18 08:22:54 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
2012-08-17 13:16:50 +00:00
|
|
|
|
using MediaBrowser.Model.DTO;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public class ItemHandler : BaseJsonHandler<DTOBaseItem>
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-08-19 20:38:31 +00:00
|
|
|
|
protected async override Task<DTOBaseItem> GetObjectToSerialize()
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-08-15 13:20:29 +00:00
|
|
|
|
Guid userId = Guid.Parse(QueryString["userid"]);
|
2012-08-18 08:22:54 +00:00
|
|
|
|
User user = Kernel.Instance.Users.First(u => u.Id == userId);
|
2012-08-15 13:20:29 +00:00
|
|
|
|
|
|
|
|
|
BaseItem item = ItemToSerialize;
|
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-08-19 20:38:31 +00:00
|
|
|
|
return await ApiService.GetDTOBaseItem(item, user);
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 03:50:50 +00:00
|
|
|
|
protected virtual BaseItem ItemToSerialize
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
get
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
return ApiService.GetItemById(QueryString["id"]);
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|