Created an ItemsByName query dto

This commit is contained in:
LukePulverenti 2013-03-02 02:16:52 -05:00
parent 79baaa4daa
commit e8f5fade43
14 changed files with 94 additions and 38 deletions

View File

@ -359,7 +359,8 @@ namespace MediaBrowser.Api.Images
break;
}
var extension = mimeType.Substring(mimeType.IndexOf('/') + 1);
var extension = mimeType.Split(';').First().Split('/').Last();
var oldImagePath = entity.GetImage(imageType);

View File

@ -82,7 +82,9 @@ namespace MediaBrowser.Api.UserLibrary
}
var tasks = ibnItems.Select(i => GetDto(i, user, new List<ItemFields>()));
var fields = GetItemFields(request).ToList();
var tasks = ibnItems.Select(i => GetDto(i, user, fields));
var resultItems = await Task.WhenAll(tasks).ConfigureAwait(false);
@ -91,6 +93,23 @@ namespace MediaBrowser.Api.UserLibrary
return result;
}
/// <summary>
/// Gets the item fields.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>IEnumerable{ItemFields}.</returns>
private IEnumerable<ItemFields> GetItemFields(GetItemsByName request)
{
var val = request.Fields;
if (string.IsNullOrEmpty(val))
{
return new ItemFields[] { };
}
return val.Split(',').Select(v => (ItemFields)Enum.Parse(typeof(ItemFields), v, true));
}
/// <summary>
/// Gets all items.
/// </summary>
@ -171,5 +190,10 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <value>The item id.</value>
public string Id { get; set; }
/// <summary>
/// Fields to return within the items, in addition to basic information
/// </summary>
/// <value>The fields.</value>
public string Fields { get; set; }
}
}

View File

@ -60,7 +60,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class UpdateDisplayPreferences
/// </summary>
[Route("/Users/{UserId}/Items/{Id}/DisplayPreferences", "GET")]
[Route("/Users/{UserId}/Items/{Id}/DisplayPreferences", "POST")]
[ServiceStack.ServiceHost.Api(("Updates a user's display preferences for an item"))]
public class UpdateDisplayPreferences : IReturnVoid, IRequiresRequestStream
{

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Common.Implementations
/// <summary>
/// The _use debug path
/// </summary>
private bool _useDebugPath;
private readonly bool _useDebugPath;
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.

View File

@ -404,7 +404,7 @@ namespace MediaBrowser.Common.Kernel
}
catch (FileNotFoundException)
{
configuration = ApplicationHost.CreateInstance(type);
configuration = Activator.CreateInstance(type);
}
// Take the object we just got and serialize it back to bytes

View File

@ -295,10 +295,6 @@ namespace MediaBrowser.Common.Plugins
{
InitializeOnServer(!File.Exists(ConfigurationFilePath));
}
else if (kernel.KernelContext == KernelContext.Ui)
{
InitializeInUi();
}
}
/// <summary>
@ -309,13 +305,6 @@ namespace MediaBrowser.Common.Plugins
{
}
/// <summary>
/// Starts the plugin in the Ui
/// </summary>
protected virtual void InitializeInUi()
{
}
/// <summary>
/// Disposes the plugins. Undos all actions performed during Init.
/// </summary>
@ -335,10 +324,6 @@ namespace MediaBrowser.Common.Plugins
{
DisposeOnServer(dispose);
}
else if (Kernel.KernelContext == KernelContext.Ui)
{
DisposeInUI(dispose);
}
}
/// <summary>
@ -350,15 +335,6 @@ namespace MediaBrowser.Common.Plugins
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void DisposeInUI(bool dispose)
{
}
/// <summary>
/// The _save lock
/// </summary>

View File

@ -56,9 +56,6 @@
<Reference Include="Mediabrowser.PluginSecurity">
<HintPath>Plugins\Mediabrowser.PluginSecurity.dll</HintPath>
</Reference>
<Reference Include="MoreLinq">
<HintPath>..\packages\morelinq.1.0.15631-beta\lib\net35\MoreLinq.dll</HintPath>
</Reference>
<Reference Include="protobuf-net, Version=2.0.0.621, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="morelinq" version="1.0.15631-beta" targetFramework="net45" />
<package id="protobuf-net" version="2.0.0.621" targetFramework="net45" />
</packages>

View File

@ -631,6 +631,12 @@ namespace MediaBrowser.Model.Dto
get { return string.Equals(MediaType, Entities.MediaType.Game, StringComparison.OrdinalIgnoreCase); }
}
[IgnoreDataMember]
public bool IsPerson
{
get { return string.Equals(Type, "Person", StringComparison.OrdinalIgnoreCase); }
}
/// <summary>
/// Occurs when [property changed].
/// </summary>

View File

@ -0,0 +1,52 @@
using MediaBrowser.Model.Entities;
using System;
namespace MediaBrowser.Model.Dto
{
/// <summary>
/// Class ItemsByNameQuery
/// </summary>
public class ItemsByNameQuery
{
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <value>The user id.</value>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the start index.
/// </summary>
/// <value>The start index.</value>
public int? StartIndex { get; set; }
/// <summary>
/// Gets or sets the size of the page.
/// </summary>
/// <value>The size of the page.</value>
public int? PageSize { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="GetItemsByName" /> is recursive.
/// </summary>
/// <value><c>true</c> if recursive; otherwise, <c>false</c>.</value>
public bool Recursive { get; set; }
/// <summary>
/// Gets or sets the sort order.
/// </summary>
/// <value>The sort order.</value>
public SortOrder? SortOrder { get; set; }
/// <summary>
/// If specified the search will be localized within a specific item or folder
/// </summary>
/// <value>The item id.</value>
public string ItemId { get; set; }
/// <summary>
/// Fields to return within the items, in addition to basic information
/// </summary>
/// <value>The fields.</value>
public ItemFields[] Fields { get; set; }
/// <summary>
/// Gets or sets the person types.
/// </summary>
/// <value>The person types.</value>
public string[] PersonTypes { get; set; }
}
}

View File

@ -44,6 +44,7 @@
<Compile Include="Configuration\ServerConfiguration.cs" />
<Compile Include="Dto\BaseItemPerson.cs" />
<Compile Include="Dto\ChapterInfoDto.cs" />
<Compile Include="Dto\ItemsByNameQuery.cs" />
<Compile Include="Dto\MediaType.cs" />
<Compile Include="Entities\BaseItemInfo.cs" />
<Compile Include="Connectivity\ClientConnectionInfo.cs" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.19</version>
<version>3.0.22</version>
<title />
<authors>Luke</authors>
<owners>Media Browser Team</owners>
@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption.</description>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.19" />
<dependency id="MediaBrowser.Common" version="3.0.22" />
<dependency id="NLog" version="2.0.0.2000" />
<dependency id="ServiceStack" version="3.9.37" />
<dependency id="ServiceStack.Api.Swagger" version="3.9.35" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.19</version>
<version>3.0.22</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.19</version>
<version>3.0.22</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners />
@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Contains core components required to build plugins for Media Browser Server.</description>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.19" />
<dependency id="MediaBrowser.Common" version="3.0.22" />
</dependencies>
</metadata>
<files>