Added a completely separate DTOBaseItem to remove the ApiBaseItemWrapper mess and shrink json output size.

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti
2012-08-18 04:22:54 -04:00
parent f32f000298
commit 7835d690a1
31 changed files with 587 additions and 370 deletions

View File

@@ -1,67 +0,0 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Model.DTO
{
/// <summary>
/// This is a concrete class that the UI can use to deserialize
/// It is flat in the sense that it will be used regardless of the type of BaseItem involved
/// </summary>
public class ApiBaseItem : BaseItem
{
// Series properties
public string Status { get; set; }
public IEnumerable<DayOfWeek> AirDays { get; set; }
public string AirTime { get; set; }
}
/// <summary>
/// This is the full return object when requesting an Item
/// </summary>
public class BaseItemContainer<TItemType>
where TItemType : BaseItem
{
public TItemType Item { get; set; }
public UserItemData UserItemData { get; set; }
public IEnumerable<BaseItemContainer<TItemType>> Children { get; set; }
public bool IsFolder { get; set; }
public Guid? ParentId { get; set; }
public string Type { get; set; }
public bool IsType(Type type)
{
return IsType(type.Name);
}
public bool IsType(string type)
{
return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
}
public IEnumerable<BaseItemPerson> People { get; set; }
public IEnumerable<BaseItemStudio> Studios { get; set; }
/// <summary>
/// If the item does not have a logo, this will hold the Id of the Parent that has one.
/// </summary>
public Guid? ParentLogoItemId { get; set; }
public Guid? ParentBackdropItemId { get; set; }
public int? ParentBackdropCount { get; set; }
}
/// <summary>
/// This is strictly for convenience so the UI's don't have to use the verbose generic syntax of BaseItemWrapper<ApiBaseItem>
/// </summary>
public class ApiBaseItemContainer : BaseItemContainer<ApiBaseItem>
{
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.DTO
{
public class DTOBaseItem : IHasProviderIds
{
public string Name { get; set; }
public Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public string SortName { get; set; }
public DateTime? PremiereDate { get; set; }
public string Path { get; set; }
public string OfficialRating { get; set; }
public string Overview { get; set; }
public IEnumerable<string> Taglines { get; set; }
public IEnumerable<string> Genres { get; set; }
public string DisplayMediaType { get; set; }
public float? UserRating { get; set; }
public long? RunTimeTicks { get; set; }
public string AspectRatio { get; set; }
public int? ProductionYear { get; set; }
public int? IndexNumber { get; set; }
public string TrailerUrl { get; set; }
public Dictionary<string, string> ProviderIds { get; set; }
public bool HasBanner { get; set; }
public bool HasArt { get; set; }
public bool HasLogo { get; set; }
public bool HasThumb { get; set; }
public bool HasPrimaryImage { get; set; }
public int BackdropCount { get; set; }
public IEnumerable<DTOBaseItem> Children { get; set; }
public bool IsFolder { get; set; }
public Guid? ParentId { get; set; }
public string Type { get; set; }
public IEnumerable<BaseItemPerson> People { get; set; }
public IEnumerable<BaseItemStudio> Studios { get; set; }
/// <summary>
/// If the item does not have a logo, this will hold the Id of the Parent that has one.
/// </summary>
public Guid? ParentLogoItemId { get; set; }
/// <summary>
/// If the item does not have any backdrops, this will hold the Id of the Parent that has one.
/// </summary>
public Guid? ParentBackdropItemId { get; set; }
public int? ParentBackdropCount { get; set; }
public IEnumerable<Video> LocalTrailers { get; set; }
public int LocalTrailerCount { get; set; }
/// <summary>
/// User data for this item based on the user it's being requested for
/// </summary>
public UserItemData UserData { get; set; }
public ItemSpecialCounts SpecialCounts { get; set; }
public bool IsType(Type type)
{
return IsType(type.Name);
}
public bool IsType(string type)
{
return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
}
}
}

View File

@@ -24,7 +24,7 @@ namespace MediaBrowser.Model.DTO
public class BaseItemPerson
{
public PersonInfo PersonInfo { get; set; }
public string PrimaryImagePath { get; set; }
public bool HasImage { get; set; }
}
/// <summary>
@@ -33,6 +33,6 @@ namespace MediaBrowser.Model.DTO
public class BaseItemStudio
{
public string Name { get; set; }
public string PrimaryImagePath { get; set; }
public bool HasImage { get; set; }
}
}