瀏覽代碼

Added BaseEntity so that Person, User, and other misc classes don't have to inherit from BaseItem

LukePulverenti Luke Pulverenti luke pulverenti 13 年之前
父節點
當前提交
31afb168f8

+ 4 - 8
MediaBrowser.Api/HttpHandlers/ImageHandler.cs

@@ -168,19 +168,15 @@ namespace MediaBrowser.Api.HttpHandlers
 
 
             string id = QueryString["id"];
             string id = QueryString["id"];
             string personName = QueryString["personname"];
             string personName = QueryString["personname"];
-            string imageIndex = QueryString["index"];
-
-            BaseItem item;
 
 
             if (!string.IsNullOrEmpty(personName))
             if (!string.IsNullOrEmpty(personName))
             {
             {
-                item = Kernel.Instance.ItemController.GetPerson(personName);
-            }
-            else
-            {
-                item = ApiService.GetItemById(QueryString["id"]);
+                return Kernel.Instance.ItemController.GetPerson(personName).PrimaryImagePath;
             }
             }
 
 
+            BaseItem item = ApiService.GetItemById(QueryString["id"]);
+
+            string imageIndex = QueryString["index"];
             int index = string.IsNullOrEmpty(imageIndex) ? 0 : int.Parse(imageIndex);
             int index = string.IsNullOrEmpty(imageIndex) ? 0 : int.Parse(imageIndex);
 
 
             return GetImagePathFromTypes(item, ImageType, index);
             return GetImagePathFromTypes(item, ImageType, index);

+ 2 - 3
MediaBrowser.Api/HttpHandlers/PersonHandler.cs

@@ -1,11 +1,10 @@
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
 
 
 namespace MediaBrowser.Api.HttpHandlers
 namespace MediaBrowser.Api.HttpHandlers
 {
 {
-    public class PersonHandler : ItemHandler
+    public class PersonHandler : JsonHandler
     {
     {
-        protected override BaseItem ItemToSerialize
+        protected sealed override object ObjectToSerialize
         {
         {
             get
             get
             {
             {

+ 19 - 0
MediaBrowser.Model/Entities/BaseEntity.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MediaBrowser.Model.Entities
+{
+    /// <summary>
+    /// Provides a base entity for all of our types
+    /// </summary>
+    public abstract class BaseEntity
+    {
+        public string Name { get; set; }
+
+        public Guid Id { get; set; }
+
+        public string PrimaryImagePath { get; set; }
+    }
+}

+ 1 - 5
MediaBrowser.Model/Entities/BaseItem.cs

@@ -4,13 +4,10 @@ using System.Runtime.Serialization;
 
 
 namespace MediaBrowser.Model.Entities
 namespace MediaBrowser.Model.Entities
 {
 {
-    public abstract class BaseItem
+    public abstract class BaseItem : BaseEntity
     {
     {
-        public string Name { get; set; }
         public string SortName { get; set; }
         public string SortName { get; set; }
 
 
-        public Guid Id { get; set; }
-
         public DateTime DateCreated { get; set; }
         public DateTime DateCreated { get; set; }
 
 
         public DateTime DateModified { get; set; }
         public DateTime DateModified { get; set; }
@@ -25,7 +22,6 @@ namespace MediaBrowser.Model.Entities
         [IgnoreDataMember]
         [IgnoreDataMember]
         public Folder Parent { get; set; }
         public Folder Parent { get; set; }
 
 
-        public string PrimaryImagePath { get; set; }
         public string LogoImagePath { get; set; }
         public string LogoImagePath { get; set; }
         public string ArtImagePath { get; set; }
         public string ArtImagePath { get; set; }
         public string ThumbnailImagePath { get; set; }
         public string ThumbnailImagePath { get; set; }

+ 1 - 1
MediaBrowser.Model/Entities/Genre.cs

@@ -1,7 +1,7 @@
 
 
 namespace MediaBrowser.Model.Entities
 namespace MediaBrowser.Model.Entities
 {
 {
-    public class Genre : BaseItem
+    public class Genre : BaseEntity
     {
     {
     }
     }
 }
 }

+ 1 - 1
MediaBrowser.Model/Entities/Person.cs

@@ -4,7 +4,7 @@ namespace MediaBrowser.Model.Entities
     /// <summary>
     /// <summary>
     /// This is the full Person object that can be retrieved with all of it's data.
     /// This is the full Person object that can be retrieved with all of it's data.
     /// </summary>
     /// </summary>
-    public class Person : BaseItem
+    public class Person : BaseEntity
     {
     {
         public PersonType PersonType { get; set; }
         public PersonType PersonType { get; set; }
     }
     }

+ 1 - 1
MediaBrowser.Model/Entities/Studio.cs

@@ -1,7 +1,7 @@
 
 
 namespace MediaBrowser.Model.Entities
 namespace MediaBrowser.Model.Entities
 {
 {
-    public class Studio : BaseItem
+    public class Studio : BaseEntity
     {
     {
     }
     }
 }
 }

+ 1 - 1
MediaBrowser.Model/Entities/Year.cs

@@ -1,7 +1,7 @@
 
 
 namespace MediaBrowser.Model.Entities
 namespace MediaBrowser.Model.Entities
 {
 {
-    public class Year : BaseItem
+    public class Year : BaseEntity
     {
     {
     }
     }
 }
 }

+ 1 - 0
MediaBrowser.Model/MediaBrowser.Model.csproj

@@ -35,6 +35,7 @@
     <Compile Include="Configuration\UserConfiguration.cs" />
     <Compile Include="Configuration\UserConfiguration.cs" />
     <Compile Include="Entities\ApiBaseItem.cs" />
     <Compile Include="Entities\ApiBaseItem.cs" />
     <Compile Include="Entities\Audio.cs" />
     <Compile Include="Entities\Audio.cs" />
+    <Compile Include="Entities\BaseEntity.cs" />
     <Compile Include="Entities\BaseItem.cs" />
     <Compile Include="Entities\BaseItem.cs" />
     <Compile Include="Entities\CategoryInfo.cs" />
     <Compile Include="Entities\CategoryInfo.cs" />
     <Compile Include="Entities\Folder.cs" />
     <Compile Include="Entities\Folder.cs" />

+ 1 - 1
MediaBrowser.Model/Users/User.cs

@@ -4,7 +4,7 @@ using MediaBrowser.Model.Entities;
 
 
 namespace MediaBrowser.Model.Users
 namespace MediaBrowser.Model.Users
 {
 {
-    public class User : BaseItem
+    public class User : BaseEntity
     {
     {
         public string MaxParentalRating { get; set; }
         public string MaxParentalRating { get; set; }