basic item saving

pull/702/head
Luke Pulverenti 12 years ago
parent 657097ee15
commit 74d761c981

@ -127,6 +127,13 @@ namespace MediaBrowser.Api
public Guid? UserId { get; set; } public Guid? UserId { get; set; }
} }
[Route("/Items/{ItemId}", "POST")]
[Api(("Updates an item"))]
public class UpdateItem : BaseItemDto, IReturnVoid
{
public string ItemId { get; set; }
}
/// <summary> /// <summary>
/// Class LibraryService /// Class LibraryService
/// </summary> /// </summary>
@ -147,6 +154,7 @@ namespace MediaBrowser.Api
/// <param name="itemRepo">The item repo.</param> /// <param name="itemRepo">The item repo.</param>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="userManager">The user manager.</param> /// <param name="userManager">The user manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
IUserDataRepository userDataRepository) IUserDataRepository userDataRepository)
{ {
@ -222,6 +230,67 @@ namespace MediaBrowser.Api
} }
} }
public void Post(UpdateItem request)
{
var task = UpdateItem(request);
Task.WaitAll(task);
}
private Task UpdateItem(UpdateItem request)
{
var item = DtoBuilder.GetItemByClientId(request.ItemId, _userManager, _libraryManager);
item.Name = request.Name;
item.ForcedSortName = request.SortName;
item.DisplayMediaType = request.DisplayMediaType;
item.CommunityRating = request.CommunityRating;
item.HomePageUrl = request.HomePageUrl;
item.Budget = request.Budget;
item.Revenue = request.Revenue;
item.CriticRating = request.CriticRating;
item.CriticRatingSummary = request.CriticRatingSummary;
item.IndexNumber = request.IndexNumber;
item.ParentIndexNumber = request.ParentIndexNumber;
item.EndDate = request.EndDate;
item.PremiereDate = request.PremiereDate;
item.ProductionYear = request.ProductionYear;
item.AspectRatio = request.AspectRatio;
item.Language = request.Language;
item.OfficialRating = request.OfficialRating;
item.CustomRating = request.CustomRating;
foreach (var pair in request.ProviderIds.ToList())
{
if (string.IsNullOrEmpty(pair.Value))
{
request.ProviderIds.Remove(pair.Key);
}
}
item.ProviderIds = request.ProviderIds;
var game = item as BaseGame;
if (game != null)
{
game.PlayersSupported = request.Players;
}
var song = item as Audio;
if (song != null)
{
song.Album = request.Album;
song.AlbumArtist = request.AlbumArtist;
song.Artist = request.Artists[0];
}
return _libraryManager.UpdateItem(item, CancellationToken.None);
}
/// <summary> /// <summary>
/// Deletes the specified request. /// Deletes the specified request.
/// </summary> /// </summary>

@ -66,6 +66,12 @@ namespace MediaBrowser.Model.Dto
/// <value>The official rating.</value> /// <value>The official rating.</value>
public string OfficialRating { get; set; } public string OfficialRating { get; set; }
/// <summary>
/// Gets or sets the custom rating.
/// </summary>
/// <value>The custom rating.</value>
public string CustomRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the overview. /// Gets or sets the overview.
/// </summary> /// </summary>

@ -1714,6 +1714,22 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
}); });
}; };
self.updateItem = function (item) {
if (!item) {
throw new Error("null item");
}
var url = self.getUrl("Items/" + item.Id);
return self.ajax({
type: "POST",
url: url,
data: JSON.stringify(item),
contentType: "application/json"
});
};
/** /**
* Updates plugin security info * Updates plugin security info
*/ */

@ -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.119" targetFramework="net45" /> <package id="MediaBrowser.ApiClient.Javascript" version="3.0.120" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.46" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.46" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.45" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.45" targetFramework="net45" />
</packages> </packages>
Loading…
Cancel
Save