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

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-12 19:57:54 -04:00
parent 16593b3350
commit 31afb168f8
10 changed files with 32 additions and 21 deletions

View File

@ -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); return Kernel.Instance.ItemController.GetPerson(personName).PrimaryImagePath;
}
else
{
item = ApiService.GetItemById(QueryString["id"]);
} }
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);

View File

@ -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
{ {

View File

@ -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; }
}
}

View File

@ -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; }

View File

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

View File

@ -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; }
} }

View File

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

View File

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

View File

@ -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" />

View File

@ -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; }