|
|
|
@ -91,28 +91,39 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
|
|
|
|
var userData = GetUserData(user, item);
|
|
|
|
|
|
|
|
|
|
var parentProperties = userDataDto.GetType().GetProperties();
|
|
|
|
|
var childProperties = userData.GetType().GetProperties();
|
|
|
|
|
if (userDataDto.PlaybackPositionTicks.HasValue)
|
|
|
|
|
{
|
|
|
|
|
userData.PlaybackPositionTicks = userDataDto.PlaybackPositionTicks.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var parentProperty in parentProperties)
|
|
|
|
|
if (userDataDto.PlayCount.HasValue)
|
|
|
|
|
{
|
|
|
|
|
foreach (var childProperty in childProperties)
|
|
|
|
|
{
|
|
|
|
|
if (parentProperty.Name != childProperty.Name)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
userData.PlayCount = userDataDto.PlayCount.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var value = parentProperty.GetValue(userDataDto, null);
|
|
|
|
|
if (userDataDto.IsFavorite.HasValue)
|
|
|
|
|
{
|
|
|
|
|
userData.IsFavorite = userDataDto.IsFavorite.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value is null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (userDataDto.Likes.HasValue)
|
|
|
|
|
{
|
|
|
|
|
userData.Likes = userDataDto.Likes.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
childProperty.SetValue(userData, value, null);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (userDataDto.Played.HasValue)
|
|
|
|
|
{
|
|
|
|
|
userData.Played = userDataDto.Played.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userDataDto.LastPlayedDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
userData.LastPlayedDate = userDataDto.LastPlayedDate.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userDataDto.Rating.HasValue)
|
|
|
|
|
{
|
|
|
|
|
userData.Rating = userDataDto.Rating.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SaveUserData(user, item, userData, reason, CancellationToken.None);
|
|
|
|
|