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 personName = QueryString["personname"];
string imageIndex = QueryString["index"];
BaseItem item;
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);
return GetImagePathFromTypes(item, ImageType, index);

View file

@ -1,11 +1,10 @@
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class PersonHandler : ItemHandler
public class PersonHandler : JsonHandler
{
protected override BaseItem ItemToSerialize
protected sealed override object ObjectToSerialize
{
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
{
public abstract class BaseItem
public abstract class BaseItem : BaseEntity
{
public string Name { get; set; }
public string SortName { get; set; }
public Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateModified { get; set; }
@ -25,7 +22,6 @@ namespace MediaBrowser.Model.Entities
[IgnoreDataMember]
public Folder Parent { get; set; }
public string PrimaryImagePath { get; set; }
public string LogoImagePath { get; set; }
public string ArtImagePath { get; set; }
public string ThumbnailImagePath { get; set; }

View file

@ -1,7 +1,7 @@

namespace MediaBrowser.Model.Entities
{
public class Genre : BaseItem
public class Genre : BaseEntity
{
}
}

View file

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

View file

@ -1,7 +1,7 @@

namespace MediaBrowser.Model.Entities
{
public class Studio : BaseItem
public class Studio : BaseEntity
{
}
}

View file

@ -1,7 +1,7 @@

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="Entities\ApiBaseItem.cs" />
<Compile Include="Entities\Audio.cs" />
<Compile Include="Entities\BaseEntity.cs" />
<Compile Include="Entities\BaseItem.cs" />
<Compile Include="Entities\CategoryInfo.cs" />
<Compile Include="Entities\Folder.cs" />

View file

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