fixed userdata calls

This commit is contained in:
Luke Pulverenti 2013-03-29 13:25:12 -04:00
parent 47d10bcee8
commit a0834c5710
3 changed files with 21 additions and 11 deletions

View File

@ -78,7 +78,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Class UpdateDisplayPreferences /// Class UpdateDisplayPreferences
/// </summary> /// </summary>
[Route("/Users/{UserId}/Items/{Id}/DisplayPreferences", "POST")] [Route("/Users/{UserId}/Items/{Id}/DisplayPreferences", "POST")]
[ServiceStack.ServiceHost.Api(("Updates a user's display preferences for an item"))] [Api(("Updates a user's display preferences for an item"))]
public class UpdateDisplayPreferences : DisplayPreferences, IReturnVoid public class UpdateDisplayPreferences : DisplayPreferences, IReturnVoid
{ {
/// <summary> /// <summary>
@ -93,7 +93,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Class MarkFavoriteItem /// Class MarkFavoriteItem
/// </summary> /// </summary>
[Route("/Users/{UserId}/FavoriteItems/{Id}", "POST")] [Route("/Users/{UserId}/FavoriteItems/{Id}", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Marks an item as a favorite")] [Api(Description = "Marks an item as a favorite")]
public class MarkFavoriteItem : IReturnVoid public class MarkFavoriteItem : IReturnVoid
{ {
/// <summary> /// <summary>
@ -115,7 +115,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Class UnmarkFavoriteItem /// Class UnmarkFavoriteItem
/// </summary> /// </summary>
[Route("/Users/{UserId}/FavoriteItems/{Id}", "DELETE")] [Route("/Users/{UserId}/FavoriteItems/{Id}", "DELETE")]
[ServiceStack.ServiceHost.Api(Description = "Unmarks an item as a favorite")] [Api(Description = "Unmarks an item as a favorite")]
public class UnmarkFavoriteItem : IReturnVoid public class UnmarkFavoriteItem : IReturnVoid
{ {
/// <summary> /// <summary>
@ -498,7 +498,7 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
var item = (Folder)DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
// Get the user data for this item // Get the user data for this item
var data = item.GetUserData(user, true); var data = item.GetUserData(user, true);
@ -519,7 +519,7 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
var item = (Folder)DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
// Get the user data for this item // Get the user data for this item
var data = item.GetUserData(user, true); var data = item.GetUserData(user, true);
@ -540,7 +540,7 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
var item = (Folder)DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
// Get the user data for this item // Get the user data for this item
var data = item.GetUserData(user, true); var data = item.GetUserData(user, true);
@ -560,7 +560,7 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
var item = (Folder)DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
// Get the user data for this item // Get the user data for this item
var data = item.GetUserData(user, true); var data = item.GetUserData(user, true);

View File

@ -213,7 +213,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
*/ */
self.getRootFolder = function (userId) { self.getRootFolder = function (userId) {
return self.getItem(userId); if (!userId) {
throw new Error("null userId");
}
var url = self.getUrl("Users/" + userId + "/Items/Root");
return self.ajax({
type: "GET",
url: url,
dataType: "json"
});
}; };
/** /**
@ -1577,7 +1587,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null itemId"); throw new Error("null itemId");
} }
var url = "Users/" + userId + "/PlayedItems/" + itemId; var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId);
var method = wasPlayed ? "POST" : "DELETE"; var method = wasPlayed ? "POST" : "DELETE";
@ -1604,7 +1614,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null itemId"); throw new Error("null itemId");
} }
var url = "Users/" + userId + "/FavoriteItems/" + itemId; var url = self.getUrl("Users/" + userId + "/FavoriteItems/" + itemId);
var method = isFavorite ? "POST" : "DELETE"; var method = isFavorite ? "POST" : "DELETE";

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.68" targetFramework="net45" /> <package id="MediaBrowser.ApiClient.Javascript" version="3.0.70" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.42" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.42" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.42" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.42" targetFramework="net45" />
</packages> </packages>