From b3cb8fda22337e22d6d4ee45d5ec6e9cf69be7fa Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 12 Apr 2013 20:42:51 -0400 Subject: add ability to mark studios, genres and people as favorites --- MediaBrowser.Api/UserLibrary/GenresService.cs | 63 ++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Api/UserLibrary/GenresService.cs') diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.cs index 13c441c63..54561f400 100644 --- a/MediaBrowser.Api/UserLibrary/GenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GenresService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System.Threading; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using ServiceStack.ServiceHost; using System; @@ -18,6 +19,44 @@ namespace MediaBrowser.Api.UserLibrary { } + [Route("/Users/{UserId}/FavoriteGenres/{Name}", "POST")] + [Api(Description = "Marks a genre as a favorite")] + public class MarkFavoriteGenre : IReturnVoid + { + /// + /// Gets or sets the user id. + /// + /// The user id. + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid UserId { get; set; } + + /// + /// Gets or sets the name. + /// + /// The name. + [ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] + public string Name { get; set; } + } + + [Route("/Users/{UserId}/FavoriteGenres/{Name}", "DELETE")] + [Api(Description = "Unmarks a genre as a favorite")] + public class UnmarkFavoriteGenre : IReturnVoid + { + /// + /// Gets or sets the user id. + /// + /// The user id. + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] + public Guid UserId { get; set; } + + /// + /// Gets or sets the name. + /// + /// The name. + [ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] + public string Name { get; set; } + } + /// /// Class GenresService /// @@ -40,6 +79,28 @@ namespace MediaBrowser.Api.UserLibrary return ToOptimizedResult(result); } + /// + /// Posts the specified request. + /// + /// The request. + public void Post(MarkFavoriteGenre request) + { + var task = MarkFavorite(() => LibraryManager.GetGenre(request.Name), request.UserId, true); + + Task.WaitAll(task); + } + + /// + /// Deletes the specified request. + /// + /// The request. + public void Delete(UnmarkFavoriteGenre request) + { + var task = MarkFavorite(() => LibraryManager.GetGenre(request.Name), request.UserId, false); + + Task.WaitAll(task); + } + /// /// Gets all items. /// -- cgit v1.2.3