From 7835d690a1ade4739171036cff335c86b5232d0e Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Sat, 18 Aug 2012 04:22:54 -0400 Subject: Added a completely separate DTOBaseItem to remove the ApiBaseItemWrapper mess and shrink json output size. --- MediaBrowser.Model/Entities/BaseItem.cs | 65 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 34 deletions(-) (limited to 'MediaBrowser.Model/Entities/BaseItem.cs') diff --git a/MediaBrowser.Model/Entities/BaseItem.cs b/MediaBrowser.Model/Entities/BaseItem.cs index c9d5b936b..506c051c5 100644 --- a/MediaBrowser.Model/Entities/BaseItem.cs +++ b/MediaBrowser.Model/Entities/BaseItem.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; -using System.Runtime.Serialization; -using MediaBrowser.Model.Users; +using System.Linq; namespace MediaBrowser.Model.Entities { - public abstract class BaseItem : BaseEntity + public abstract class BaseItem : BaseEntity, IHasProviderIds { public string SortName { get; set; } @@ -16,25 +15,25 @@ namespace MediaBrowser.Model.Entities public string Path { get; set; } - [IgnoreDataMember] public Folder Parent { get; set; } public string LogoImagePath { get; set; } + public string ArtImagePath { get; set; } + public string ThumbnailImagePath { get; set; } + public string BannerImagePath { get; set; } public IEnumerable BackdropImagePaths { get; set; } public string OfficialRating { get; set; } - [IgnoreDataMember] public string CustomRating { get; set; } public string Overview { get; set; } - public string Tagline { get; set; } + public IEnumerable Taglines { get; set; } - [IgnoreDataMember] public IEnumerable People { get; set; } public IEnumerable Studios { get; set; } @@ -44,7 +43,7 @@ namespace MediaBrowser.Model.Entities public string DisplayMediaType { get; set; } public float? UserRating { get; set; } - public int? RunTimeInMilliseconds { get; set; } + public long? RunTimeTicks { get; set; } public string AspectRatio { get; set; } public int? ProductionYear { get; set; } @@ -61,54 +60,52 @@ namespace MediaBrowser.Model.Entities public Dictionary ProviderIds { get; set; } - /// - /// Gets a provider id - /// - public string GetProviderId(MetadataProviders provider) - { - return GetProviderId(provider.ToString()); - } + public Dictionary UserData { get; set; } - /// - /// Gets a provider id - /// - public string GetProviderId(string name) + public UserItemData GetUserData(User user) { - if (ProviderIds == null) + if (UserData == null || !UserData.ContainsKey(user.Id)) { return null; } - return ProviderIds[name]; + return UserData[user.Id]; } - /// - /// Sets a provider id - /// - public void SetProviderId(string name, string value) + public void AddUserData(User user, UserItemData data) { - if (ProviderIds == null) + if (UserData == null) { - ProviderIds = new Dictionary(); + UserData = new Dictionary(); } - ProviderIds[name] = value; + UserData[user.Id] = data; } /// - /// Sets a provider id + /// Determines if a given user has access to this item /// - public void SetProviderId(MetadataProviders provider, string value) + internal bool IsParentalAllowed(User user) { - SetProviderId(provider.ToString(), value); + return true; } /// - /// Determines if a given user has access to this item + /// Finds an item by ID, recursively /// - internal bool IsParentalAllowed(User user) + public virtual BaseItem FindItemById(Guid id) { - return true; + if (Id == id) + { + return this; + } + + if (LocalTrailers != null) + { + return LocalTrailers.FirstOrDefault(i => i.Id == id); + } + + return null; } } } -- cgit v1.2.3