2013-04-13 18:02:30 +00:00
|
|
|
|
using MediaBrowser.Controller.Dto;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-04-13 18:02:30 +00:00
|
|
|
|
using MediaBrowser.Controller.Persistence;
|
2013-05-09 17:38:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Session;
|
2013-02-21 17:50:46 +00:00
|
|
|
|
using MediaBrowser.Model.Dto;
|
2013-03-10 05:36:39 +00:00
|
|
|
|
using MediaBrowser.Model.Querying;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using ServiceStack.ServiceHost;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2013-04-05 17:10:55 +00:00
|
|
|
|
using System.Threading;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.UserLibrary
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}", "GET")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Gets an item from a user's library")]
|
2013-02-21 17:50:46 +00:00
|
|
|
|
public class GetItem : IReturn<BaseItemDto>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-09 02:34:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/Items/Root", "GET")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Gets the root folder from a user's library")]
|
2013-03-09 02:34:54 +00:00
|
|
|
|
public class GetRootFolder : IReturn<BaseItemDto>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetIntros
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/Intros", "GET")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(("Gets intros to play before the main media item plays"))]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class GetIntros : IReturn<List<string>>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the item id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The item id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class MarkFavoriteItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/FavoriteItems/{Id}", "POST")]
|
2013-03-29 17:25:12 +00:00
|
|
|
|
[Api(Description = "Marks an item as a favorite")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class MarkFavoriteItem : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class UnmarkFavoriteItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/FavoriteItems/{Id}", "DELETE")]
|
2013-03-29 17:25:12 +00:00
|
|
|
|
[Api(Description = "Unmarks an item as a favorite")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class UnmarkFavoriteItem : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class ClearUserItemRating
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/Rating", "DELETE")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Deletes a user's saved personal rating for an item")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class DeleteUserItemRating : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class UpdateUserItemRating
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/Rating", "POST")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Updates a user's rating for an item")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class UpdateUserItemRating : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// Gets or sets a value indicating whether this <see cref="UpdateUserItemRating" /> is likes.
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if likes; otherwise, <c>false</c>.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Likes", Description = "Whether the user likes the item or not. true/false", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public bool Likes { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class MarkPlayedItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/PlayedItems/{Id}", "POST")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Marks an item as played")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class MarkPlayedItem : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class MarkUnplayedItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Users/{UserId}/PlayedItems/{Id}", "DELETE")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Marks an item as unplayed")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class MarkUnplayedItem : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class OnPlaybackStart
|
|
|
|
|
/// </summary>
|
2013-02-25 02:41:51 +00:00
|
|
|
|
[Route("/Users/{UserId}/PlayingItems/{Id}", "POST")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Reports that a user has begun playing an item")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public class OnPlaybackStart : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class OnPlaybackProgress
|
|
|
|
|
/// </summary>
|
2013-02-25 02:41:51 +00:00
|
|
|
|
[Route("/Users/{UserId}/PlayingItems/{Id}/Progress", "POST")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Reports a user's playback progress")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public class OnPlaybackProgress : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the position ticks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The position ticks.</value>
|
2013-03-09 05:15:51 +00:00
|
|
|
|
[ApiMember(Name = "PositionTicks", Description = "Optional. The current position, in ticks. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "POST")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public long? PositionTicks { get; set; }
|
2013-05-10 12:18:07 +00:00
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "IsPaused", Description = "Indicates if the player is paused.", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "POST")]
|
|
|
|
|
public bool IsPaused { get; set; }
|
2013-02-25 02:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class OnPlaybackStopped
|
|
|
|
|
/// </summary>
|
2013-02-25 02:41:51 +00:00
|
|
|
|
[Route("/Users/{UserId}/PlayingItems/{Id}", "DELETE")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Reports that a user has stopped playing an item")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public class OnPlaybackStopped : IReturnVoid
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the position ticks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The position ticks.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "PositionTicks", Description = "Optional. The position, in ticks, where playback stopped. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "DELETE")]
|
2013-02-25 02:41:51 +00:00
|
|
|
|
public long? PositionTicks { get; set; }
|
|
|
|
|
}
|
2013-04-24 16:37:12 +00:00
|
|
|
|
|
2013-02-24 21:53:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetLocalTrailers
|
|
|
|
|
/// </summary>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/LocalTrailers", "GET")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Gets local trailers for an item")]
|
2013-02-21 17:50:46 +00:00
|
|
|
|
public class GetLocalTrailers : IReturn<List<BaseItemDto>>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetThemeSongs
|
|
|
|
|
/// </summary>
|
2013-04-24 16:03:10 +00:00
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/ThemeSongs", "GET")]
|
|
|
|
|
[Api(Description = "Gets theme songs for an item")]
|
2013-04-24 16:37:12 +00:00
|
|
|
|
public class GetThemeSongs : IReturn<ThemeSongsResult>
|
2013-04-24 16:03:10 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-28 16:25:14 +00:00
|
|
|
|
/// <summary>
|
2013-04-28 18:30:58 +00:00
|
|
|
|
/// Class GetThemeVideos
|
2013-04-28 16:25:14 +00:00
|
|
|
|
/// </summary>
|
2013-04-28 18:30:58 +00:00
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/ThemeVideos", "GET")]
|
2013-04-28 16:25:14 +00:00
|
|
|
|
[Api(Description = "Gets video backdrops for an item")]
|
2013-04-28 18:30:58 +00:00
|
|
|
|
public class GetThemeVideos : IReturn<ThemeVideosResult>
|
2013-04-28 16:25:14 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 21:53:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetSpecialFeatures
|
|
|
|
|
/// </summary>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
[Route("/Users/{UserId}/Items/{Id}/SpecialFeatures", "GET")]
|
2013-04-05 17:10:55 +00:00
|
|
|
|
[Api(Description = "Gets special features for a movie")]
|
2013-02-21 17:50:46 +00:00
|
|
|
|
public class GetSpecialFeatures : IReturn<List<BaseItemDto>>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The user id.</value>
|
2013-03-08 22:41:38 +00:00
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The id.</value>
|
2013-03-08 23:10:37 +00:00
|
|
|
|
[ApiMember(Name = "Id", Description = "Movie Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class UserLibraryService
|
|
|
|
|
/// </summary>
|
2013-03-16 05:52:33 +00:00
|
|
|
|
public class UserLibraryService : BaseApiService
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _user manager
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IUserManager _userManager;
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _user data repository
|
|
|
|
|
/// </summary>
|
2013-04-13 18:02:30 +00:00
|
|
|
|
private readonly IUserDataRepository _userDataRepository;
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _library manager
|
|
|
|
|
/// </summary>
|
2013-02-28 19:32:41 +00:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
2013-04-24 16:37:12 +00:00
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
private readonly IItemRepository _itemRepo;
|
|
|
|
|
|
2013-05-09 17:38:02 +00:00
|
|
|
|
private readonly ISessionManager _sessionManager;
|
|
|
|
|
|
2013-02-24 21:53:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="UserLibraryService" /> class.
|
|
|
|
|
/// </summary>
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <param name="userManager">The user manager.</param>
|
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
|
|
|
/// <param name="userDataRepository">The user data repository.</param>
|
2013-05-08 20:58:52 +00:00
|
|
|
|
/// <param name="itemRepo">The item repo.</param>
|
2013-02-24 21:53:54 +00:00
|
|
|
|
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
2013-05-09 17:38:02 +00:00
|
|
|
|
public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, ISessionManager sessionManager)
|
2013-02-24 21:53:54 +00:00
|
|
|
|
: base()
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
_userManager = userManager;
|
2013-02-28 19:32:41 +00:00
|
|
|
|
_libraryManager = libraryManager;
|
2013-04-13 18:02:30 +00:00
|
|
|
|
_userDataRepository = userDataRepository;
|
2013-05-08 20:58:52 +00:00
|
|
|
|
_itemRepo = itemRepo;
|
2013-05-09 17:38:02 +00:00
|
|
|
|
_sessionManager = sessionManager;
|
2013-02-24 21:53:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public object Get(GetSpecialFeatures request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
// Get everything
|
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
|
|
|
|
|
|
var movie = (Movie)item;
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
2013-02-22 01:26:35 +00:00
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
var items = _itemRepo.GetItems(movie.SpecialFeatureIds).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).Select(t => t.Result).ToList();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(items);
|
|
|
|
|
}
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public object Get(GetLocalTrailers request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
// Get everything
|
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
2013-02-22 01:26:35 +00:00
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
var items = _itemRepo.GetItems(item.LocalTrailerIds).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).Select(t => t.Result).ToList();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(items);
|
|
|
|
|
}
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-04-24 16:03:10 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
|
public object Get(GetThemeSongs request)
|
|
|
|
|
{
|
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
|
|
|
|
|
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
|
|
|
|
|
|
|
|
|
// Get everything
|
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
|
|
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
var items = _itemRepo.GetItems(item.ThemeSongIds).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).Select(t => t.Result).ToArray();
|
2013-04-24 16:03:10 +00:00
|
|
|
|
|
2013-04-24 16:37:12 +00:00
|
|
|
|
var result = new ThemeSongsResult
|
|
|
|
|
{
|
|
|
|
|
Items = items,
|
|
|
|
|
TotalRecordCount = items.Length,
|
|
|
|
|
OwnerId = DtoBuilder.GetClientItemId(item)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
2013-04-24 16:03:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-28 16:25:14 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
2013-04-28 18:30:58 +00:00
|
|
|
|
public object Get(GetThemeVideos request)
|
2013-04-28 16:25:14 +00:00
|
|
|
|
{
|
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
|
|
|
|
|
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
|
|
|
|
|
|
|
|
|
// Get everything
|
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
|
|
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
var items = _itemRepo.GetItems(item.ThemeVideoIds).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).Select(t => t.Result).ToArray();
|
2013-04-28 16:25:14 +00:00
|
|
|
|
|
2013-04-28 18:30:58 +00:00
|
|
|
|
var result = new ThemeVideosResult
|
2013-04-28 16:25:14 +00:00
|
|
|
|
{
|
|
|
|
|
Items = items,
|
|
|
|
|
TotalRecordCount = items.Length,
|
|
|
|
|
OwnerId = DtoBuilder.GetClientItemId(item)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
|
public object Get(GetItem request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
// Get everything
|
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
2013-02-22 01:26:35 +00:00
|
|
|
|
|
2013-03-12 22:49:45 +00:00
|
|
|
|
var result = dtoBuilder.GetBaseItemDto(item, user, fields).Result;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 16:37:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
2013-03-09 02:34:54 +00:00
|
|
|
|
public object Get(GetRootFolder request)
|
|
|
|
|
{
|
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
|
|
|
|
|
|
|
|
|
var item = user.RootFolder;
|
|
|
|
|
|
|
|
|
|
// Get everything
|
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
2013-03-09 02:34:54 +00:00
|
|
|
|
|
2013-03-12 22:49:45 +00:00
|
|
|
|
var result = dtoBuilder.GetBaseItemDto(item, user, fields).Result;
|
2013-03-09 02:34:54 +00:00
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
2013-04-24 16:37:12 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
|
public object Get(GetIntros request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-02 02:44:46 +00:00
|
|
|
|
var result = _libraryManager.GetIntros(item, user);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Post(MarkFavoriteItem request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
// Get the user data for this item
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var key = item.GetUserDataKey();
|
|
|
|
|
|
|
|
|
|
var data = _userDataRepository.GetUserData(user.Id, key).Result;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
// Set favorite status
|
|
|
|
|
data.IsFavorite = true;
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var task = _userDataRepository.SaveUserData(user.Id, key, data, CancellationToken.None);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Delete(UnmarkFavoriteItem request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var key = item.GetUserDataKey();
|
2013-04-24 16:37:12 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
// Get the user data for this item
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var data = _userDataRepository.GetUserData(user.Id, key).Result;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
// Set favorite status
|
|
|
|
|
data.IsFavorite = false;
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var task = _userDataRepository.SaveUserData(user.Id, key, data, CancellationToken.None);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Delete(DeleteUserItemRating request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var key = item.GetUserDataKey();
|
2013-04-24 16:37:12 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
// Get the user data for this item
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var data = _userDataRepository.GetUserData(user.Id, key).Result;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
data.Rating = null;
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var task = _userDataRepository.SaveUserData(user.Id, key, data, CancellationToken.None);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Post(UpdateUserItemRating request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-03-31 17:39:28 +00:00
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var key = item.GetUserDataKey();
|
2013-04-24 16:37:12 +00:00
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
// Get the user data for this item
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var data = _userDataRepository.GetUserData(user.Id, key).Result;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
data.Likes = request.Likes;
|
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
var task = _userDataRepository.SaveUserData(user.Id, key, data, CancellationToken.None);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Post(MarkPlayedItem request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
var task = UpdatePlayedStatus(user, request.Id, true);
|
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-25 02:41:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Post(OnPlaybackStart request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-02-28 19:32:41 +00:00
|
|
|
|
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-03-23 04:04:36 +00:00
|
|
|
|
var auth = RequestFilterAttribute.GetAuthorization(RequestContext);
|
2013-03-16 05:52:33 +00:00
|
|
|
|
|
|
|
|
|
if (auth != null)
|
|
|
|
|
{
|
2013-05-09 17:38:02 +00:00
|
|
|
|
_sessionManager.OnPlaybackStart(user, item, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
|
2013-03-16 05:52:33 +00:00
|
|
|
|
}
|
2013-02-25 02:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Post(OnPlaybackProgress request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-02-28 19:32:41 +00:00
|
|
|
|
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-03-23 04:04:36 +00:00
|
|
|
|
var auth = RequestFilterAttribute.GetAuthorization(RequestContext);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-03-16 05:52:33 +00:00
|
|
|
|
if (auth != null)
|
|
|
|
|
{
|
2013-05-10 12:18:07 +00:00
|
|
|
|
var task = _sessionManager.OnPlaybackProgress(user, item, request.PositionTicks, request.IsPaused, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
|
2013-03-16 05:52:33 +00:00
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
2013-02-25 02:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
2013-03-18 03:10:21 +00:00
|
|
|
|
public void Delete(OnPlaybackStopped request)
|
2013-02-25 02:41:51 +00:00
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-02-28 19:32:41 +00:00
|
|
|
|
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-03-23 04:04:36 +00:00
|
|
|
|
var auth = RequestFilterAttribute.GetAuthorization(RequestContext);
|
2013-02-25 02:41:51 +00:00
|
|
|
|
|
2013-03-16 05:52:33 +00:00
|
|
|
|
if (auth != null)
|
|
|
|
|
{
|
2013-05-09 17:38:02 +00:00
|
|
|
|
var task = _sessionManager.OnPlaybackStopped(user, item, request.PositionTicks, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
|
2013-03-16 05:52:33 +00:00
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
2013-02-25 02:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
public void Delete(MarkUnplayedItem request)
|
|
|
|
|
{
|
2013-02-27 20:25:45 +00:00
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
var task = UpdatePlayedStatus(user, request.Id, false);
|
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the played status.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
|
/// <param name="itemId">The item id.</param>
|
|
|
|
|
/// <param name="wasPlayed">if set to <c>true</c> [was played].</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
private Task UpdatePlayedStatus(User user, string itemId, bool wasPlayed)
|
|
|
|
|
{
|
2013-02-28 19:32:41 +00:00
|
|
|
|
var item = DtoBuilder.GetItemByClientId(itemId, _userManager, _libraryManager, user.Id);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-04-13 18:02:30 +00:00
|
|
|
|
return item.SetPlayedStatus(user, wasPlayed, _userDataRepository);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|