jellyfin/MediaBrowser.Api/HttpHandlers/ItemHandler.cs

36 lines
923 B
C#
Raw Normal View History

using System;
using System.Linq;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.DTO;
2012-07-12 06:55:27 +00:00
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class ItemHandler : BaseJsonHandler<DTOBaseItem>
2012-07-12 06:55:27 +00:00
{
protected sealed override DTOBaseItem GetObjectToSerialize()
2012-07-12 06:55:27 +00:00
{
Guid userId = Guid.Parse(QueryString["userid"]);
User user = Kernel.Instance.Users.First(u => u.Id == userId);
BaseItem item = ItemToSerialize;
if (item == null)
{
return null;
2012-07-12 06:55:27 +00:00
}
return ApiService.GetDTOBaseItem(item, user);
2012-07-12 06:55:27 +00:00
}
protected virtual BaseItem ItemToSerialize
2012-07-12 06:55:27 +00:00
{
get
2012-07-12 06:55:27 +00:00
{
return ApiService.GetItemById(QueryString["id"]);
2012-07-12 06:55:27 +00:00
}
}
}
}