diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-17 12:47:35 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-17 12:47:35 -0400 |
| commit | 5c6ec34a9cff0819957fe5e4278f6e0d1ecc1fa3 (patch) | |
| tree | 59209813ff9588bcca79a6f32124bac0acad3c1a /MediaBrowser.Api/ApiService.cs | |
| parent | 5c094afd7e79934cb02f29a9a0080ed12c7e1098 (diff) | |
Consolidated handlers that return lists of items. Renamed ApiBaseItemWrapper to ApiBaseItemContainer. Added Person and Studio DTO's to BaseItemWrapper
Diffstat (limited to 'MediaBrowser.Api/ApiService.cs')
| -rw-r--r-- | MediaBrowser.Api/ApiService.cs | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs index e4a7f71bf..25a7ff9ec 100644 --- a/MediaBrowser.Api/ApiService.cs +++ b/MediaBrowser.Api/ApiService.cs @@ -24,9 +24,9 @@ namespace MediaBrowser.Api /// <summary>
/// Takes a BaseItem and returns the actual object that will be serialized by the api
/// </summary>
- public static BaseItemWrapper<BaseItem> GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
+ public static BaseItemContainer<BaseItem> GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
{
- BaseItemWrapper<BaseItem> wrapper = new BaseItemWrapper<BaseItem>()
+ BaseItemContainer<BaseItem> wrapper = new BaseItemContainer<BaseItem>()
{
Item = item,
UserItemData = Kernel.Instance.GetUserItemData(userId, item.Id),
@@ -60,7 +60,45 @@ namespace MediaBrowser.Api wrapper.Children = Kernel.Instance.GetParentalAllowedChildren(folder, userId).Select(c => GetSerializationObject(c, false, userId));
}
- wrapper.People = item.People;
+ // Attach People by transforming them into BaseItemPerson (DTO)
+ if (item.People != null)
+ {
+ wrapper.People = item.People.Select(p =>
+ {
+ BaseItemPerson baseItemPerson = new BaseItemPerson();
+
+ baseItemPerson.PersonInfo = p;
+
+ Person ibnObject = Kernel.Instance.ItemController.GetPerson(p.Name);
+
+ if (ibnObject != null)
+ {
+ baseItemPerson.PrimaryImagePath = ibnObject.PrimaryImagePath;
+ }
+
+ return baseItemPerson;
+ });
+ }
+ }
+
+ // Attach Studios by transforming them into BaseItemStudio (DTO)
+ if (item.Studios != null)
+ {
+ wrapper.Studios = item.Studios.Select(s =>
+ {
+ BaseItemStudio baseItemStudio = new BaseItemStudio();
+
+ baseItemStudio.Name = s;
+
+ Studio ibnObject = Kernel.Instance.ItemController.GetStudio(s);
+
+ if (ibnObject != null)
+ {
+ baseItemStudio.PrimaryImagePath = ibnObject.PrimaryImagePath;
+ }
+
+ return baseItemStudio;
+ });
}
return wrapper;
|
