Removed generics from IBNItem
This commit is contained in:
parent
ef03988442
commit
4527a18738
|
@ -194,7 +194,7 @@ namespace MediaBrowser.Api
|
|||
dto.LocalTrailers = await Task.WhenAll<DTOBaseItem>(item.LocalTrailers.Select(c => GetDTOBaseItem(c, user, false, false))).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static async Task AttachPeople(DTOBaseItem dto, BaseItem item)
|
||||
{
|
||||
// Attach People by transforming them into BaseItemPerson (DTO)
|
||||
|
@ -256,5 +256,16 @@ namespace MediaBrowser.Api
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IBNItem GetIBNItem(BaseEntity entity, int itemCount)
|
||||
{
|
||||
return new IBNItem()
|
||||
{
|
||||
Id = entity.Id,
|
||||
BaseItemCount = itemCount,
|
||||
HasPrimaryImage = !string.IsNullOrEmpty(entity.PrimaryImagePath),
|
||||
Name = entity.Name
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a single genre
|
||||
/// </summary>
|
||||
public class GenreHandler : BaseJsonHandler<IBNItem<Genre>>
|
||||
public class GenreHandler : BaseJsonHandler<IBNItem>
|
||||
{
|
||||
protected override Task<IBNItem<Genre>> GetObjectToSerialize()
|
||||
protected override Task<IBNItem> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -28,7 +28,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a Genre
|
||||
/// </summary>
|
||||
private async Task<IBNItem<Genre>> GetGenre(Folder parent, User user, string name)
|
||||
private async Task<IBNItem> GetGenre(Folder parent, User user, string name)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
@ -44,11 +44,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
}
|
||||
|
||||
// Get the original entity so that we can also supply the PrimaryImagePath
|
||||
return new IBNItem<Genre>()
|
||||
{
|
||||
Item = await Kernel.Instance.ItemController.GetGenre(name).ConfigureAwait(false),
|
||||
BaseItemCount = count
|
||||
};
|
||||
return ApiService.GetIBNItem(await Kernel.Instance.ItemController.GetGenre(name).ConfigureAwait(false), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ using MediaBrowser.Model.Entities;
|
|||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
public class GenresHandler : BaseJsonHandler<IEnumerable<IBNItem<Genre>>>
|
||||
public class GenresHandler : BaseJsonHandler<IEnumerable<IBNItem>>
|
||||
{
|
||||
protected override Task<IEnumerable<IBNItem<Genre>>> GetObjectToSerialize()
|
||||
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -24,7 +24,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// Gets all genres from all recursive children of a folder
|
||||
/// The CategoryInfo class is used to keep track of the number of times each genres appears
|
||||
/// </summary>
|
||||
private async Task<IEnumerable<IBNItem<Genre>>> GetAllGenres(Folder parent, User user)
|
||||
private async Task<IEnumerable<IBNItem>> GetAllGenres(Folder parent, User user)
|
||||
{
|
||||
Dictionary<string, int> data = new Dictionary<string, int>();
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
|
||||
IEnumerable<Genre> entities = await Task.WhenAll<Genre>(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetGenre(key); })).ConfigureAwait(false);
|
||||
|
||||
return entities.Select(e => new IBNItem<Genre>() { Item = e, BaseItemCount = data[e.Name] });
|
||||
return entities.Select(e => ApiService.GetIBNItem(e, data[e.Name]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a single Person
|
||||
/// </summary>
|
||||
public class PersonHandler : BaseJsonHandler<IBNItem<Person>>
|
||||
public class PersonHandler : BaseJsonHandler<IBNItem>
|
||||
{
|
||||
protected override Task<IBNItem<Person>> GetObjectToSerialize()
|
||||
protected override Task<IBNItem> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -28,7 +28,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a Person
|
||||
/// </summary>
|
||||
private async Task<IBNItem<Person>> GetPerson(Folder parent, User user, string name)
|
||||
private async Task<IBNItem> GetPerson(Folder parent, User user, string name)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
@ -44,11 +44,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
}
|
||||
|
||||
// Get the original entity so that we can also supply the PrimaryImagePath
|
||||
return new IBNItem<Person>()
|
||||
{
|
||||
Item = await Kernel.Instance.ItemController.GetPerson(name).ConfigureAwait(false),
|
||||
BaseItemCount = count
|
||||
};
|
||||
return ApiService.GetIBNItem(await Kernel.Instance.ItemController.GetPerson(name).ConfigureAwait(false), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a single studio
|
||||
/// </summary>
|
||||
public class StudioHandler : BaseJsonHandler<IBNItem<Studio>>
|
||||
public class StudioHandler : BaseJsonHandler<IBNItem>
|
||||
{
|
||||
protected override Task<IBNItem<Studio>> GetObjectToSerialize()
|
||||
protected override Task<IBNItem> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -28,7 +28,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a Studio
|
||||
/// </summary>
|
||||
private async Task<IBNItem<Studio>> GetStudio(Folder parent, User user, string name)
|
||||
private async Task<IBNItem> GetStudio(Folder parent, User user, string name)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
@ -44,11 +44,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
}
|
||||
|
||||
// Get the original entity so that we can also supply the PrimaryImagePath
|
||||
return new IBNItem<Studio>()
|
||||
{
|
||||
Item = await Kernel.Instance.ItemController.GetStudio(name).ConfigureAwait(false),
|
||||
BaseItemCount = count
|
||||
};
|
||||
return ApiService.GetIBNItem(await Kernel.Instance.ItemController.GetStudio(name).ConfigureAwait(false), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ using MediaBrowser.Model.Entities;
|
|||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
public class StudiosHandler : BaseJsonHandler<IEnumerable<IBNItem<Studio>>>
|
||||
public class StudiosHandler : BaseJsonHandler<IEnumerable<IBNItem>>
|
||||
{
|
||||
protected override Task<IEnumerable<IBNItem<Studio>>> GetObjectToSerialize()
|
||||
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -24,7 +24,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// Gets all studios from all recursive children of a folder
|
||||
/// The CategoryInfo class is used to keep track of the number of times each studio appears
|
||||
/// </summary>
|
||||
private async Task<IEnumerable<IBNItem<Studio>>> GetAllStudios(Folder parent, User user)
|
||||
private async Task<IEnumerable<IBNItem>> GetAllStudios(Folder parent, User user)
|
||||
{
|
||||
Dictionary<string, int> data = new Dictionary<string, int>();
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
|
||||
IEnumerable<Studio> entities = await Task.WhenAll<Studio>(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetStudio(key); })).ConfigureAwait(false);
|
||||
|
||||
return entities.Select(e => new IBNItem<Studio>() { Item = e, BaseItemCount = data[e.Name] });
|
||||
return entities.Select(e => ApiService.GetIBNItem(e, data[e.Name]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a single year
|
||||
/// </summary>
|
||||
public class YearHandler : BaseJsonHandler<IBNItem<Year>>
|
||||
public class YearHandler : BaseJsonHandler<IBNItem>
|
||||
{
|
||||
protected override Task<IBNItem<Year>> GetObjectToSerialize()
|
||||
protected override Task<IBNItem> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -28,7 +28,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// <summary>
|
||||
/// Gets a Year
|
||||
/// </summary>
|
||||
private async Task<IBNItem<Year>> GetYear(Folder parent, User user, int year)
|
||||
private async Task<IBNItem> GetYear(Folder parent, User user, int year)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
@ -44,11 +44,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
}
|
||||
|
||||
// Get the original entity so that we can also supply the PrimaryImagePath
|
||||
return new IBNItem<Year>()
|
||||
{
|
||||
Item = await Kernel.Instance.ItemController.GetYear(year).ConfigureAwait(false),
|
||||
BaseItemCount = count
|
||||
};
|
||||
return ApiService.GetIBNItem(await Kernel.Instance.ItemController.GetYear(year).ConfigureAwait(false), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ using MediaBrowser.Model.Entities;
|
|||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
public class YearsHandler : BaseJsonHandler<IEnumerable<IBNItem<Year>>>
|
||||
public class YearsHandler : BaseJsonHandler<IEnumerable<IBNItem>>
|
||||
{
|
||||
protected override Task<IEnumerable<IBNItem<Year>>> GetObjectToSerialize()
|
||||
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
@ -24,7 +24,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
/// Gets all years from all recursive children of a folder
|
||||
/// The CategoryInfo class is used to keep track of the number of times each year appears
|
||||
/// </summary>
|
||||
private async Task<IEnumerable<IBNItem<Year>>> GetAllYears(Folder parent, User user)
|
||||
private async Task<IEnumerable<IBNItem>> GetAllYears(Folder parent, User user)
|
||||
{
|
||||
Dictionary<int, int> data = new Dictionary<int, int>();
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
|
||||
IEnumerable<Year> entities = await Task.WhenAll<Year>(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetYear(key); })).ConfigureAwait(false);
|
||||
|
||||
return entities.Select(e => new IBNItem<Year>() { Item = e, BaseItemCount = data[int.Parse(e.Name)] });
|
||||
return entities.Select(e => ApiService.GetIBNItem(e, data[int.Parse(e.Name)]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,26 +197,26 @@ namespace MediaBrowser.ApiInteraction
|
|||
/// <summary>
|
||||
/// Gets all Genres
|
||||
/// </summary>
|
||||
public async Task<IEnumerable<IBNItem<Genre>>> GetAllGenresAsync(Guid userId)
|
||||
public async Task<IEnumerable<IBNItem>> GetAllGenresAsync(Guid userId)
|
||||
{
|
||||
string url = ApiUrl + "/genres?userId=" + userId.ToString();
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem<Genre>>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem>>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all Years
|
||||
/// </summary>
|
||||
public async Task<IEnumerable<IBNItem<Year>>> GetAllYearsAsync(Guid userId)
|
||||
public async Task<IEnumerable<IBNItem>> GetAllYearsAsync(Guid userId)
|
||||
{
|
||||
string url = ApiUrl + "/years?userId=" + userId.ToString();
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem<Year>>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem>>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,13 +277,13 @@ namespace MediaBrowser.ApiInteraction
|
|||
/// <summary>
|
||||
/// Gets all studious
|
||||
/// </summary>
|
||||
public async Task<IEnumerable<IBNItem<Studio>>> GetAllStudiosAsync(Guid userId)
|
||||
public async Task<IEnumerable<IBNItem>> GetAllStudiosAsync(Guid userId)
|
||||
{
|
||||
string url = ApiUrl + "/studios?userId=" + userId.ToString();
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem<Studio>>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem>>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,52 +303,52 @@ namespace MediaBrowser.ApiInteraction
|
|||
/// <summary>
|
||||
/// Gets a studio
|
||||
/// </summary>
|
||||
public async Task<IBNItem<Studio>> GetStudioAsync(Guid userId, string name)
|
||||
public async Task<IBNItem> GetStudioAsync(Guid userId, string name)
|
||||
{
|
||||
string url = ApiUrl + "/studio?userId=" + userId.ToString() + "&name=" + name;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IBNItem<Studio>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IBNItem>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a genre
|
||||
/// </summary>
|
||||
public async Task<IBNItem<Genre>> GetGenreAsync(Guid userId, string name)
|
||||
public async Task<IBNItem> GetGenreAsync(Guid userId, string name)
|
||||
{
|
||||
string url = ApiUrl + "/genre?userId=" + userId.ToString() + "&name=" + name;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IBNItem<Genre>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IBNItem>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a person
|
||||
/// </summary>
|
||||
public async Task<IBNItem<Person>> GetPersonAsync(Guid userId, string name)
|
||||
public async Task<IBNItem> GetPersonAsync(Guid userId, string name)
|
||||
{
|
||||
string url = ApiUrl + "/person?userId=" + userId.ToString() + "&name=" + name;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IBNItem<Person>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IBNItem>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a year
|
||||
/// </summary>
|
||||
public async Task<IBNItem<Year>> GetYearAsync(Guid userId, int year)
|
||||
public async Task<IBNItem> GetYearAsync(Guid userId, int year)
|
||||
{
|
||||
string url = ApiUrl + "/year?userId=" + userId.ToString() + "&year=" + year;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DataSerializer.DeserializeFromStream<IBNItem<Year>>(stream);
|
||||
return DataSerializer.DeserializeFromStream<IBNItem>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a stub class used by the api to get IBN types along with their item counts
|
||||
/// </summary>
|
||||
public class IBNItem<T>
|
||||
public class IBNItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual genre, year, studio, etc
|
||||
/// The name of the person, genre, etc
|
||||
/// </summary>
|
||||
public T Item { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The id of the person, genre, etc
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public bool HasPrimaryImage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of items that have the genre, year, studio, etc
|
||||
|
|
Loading…
Reference in New Issue
Block a user