Expose new methods on UserDataManager

This commit is contained in:
Eric Reed 2014-09-20 18:14:16 -04:00
parent 93f87678c2
commit 1be6a836fb
2 changed files with 70 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
@ -43,5 +44,22 @@ namespace MediaBrowser.Controller.Library
/// <param name="user">The user.</param>
/// <returns>UserItemDataDto.</returns>
UserItemDataDto GetUserDataDto(IHasUserData item, User user);
/// <summary>
/// Get all user data for the given user
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
IEnumerable<UserItemData> GetAllUserData(Guid userId);
/// <summary>
/// Save the all provided user data for the given user
/// </summary>
/// <param name="userId"></param>
/// <param name="userData"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken);
}
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Events;
using System.Collections.Generic;
using MediaBrowser.Common.Events;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
@ -96,6 +97,55 @@ namespace MediaBrowser.Server.Implementations.Library
}, _logger);
}
/// <summary>
/// Save the provided user data for the given user. Batch operation. Does not fire any events or update the cache.
/// </summary>
/// <param name="userId"></param>
/// <param name="userData"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken)
{
if (userData == null)
{
throw new ArgumentNullException("userData");
}
if (userId == Guid.Empty)
{
throw new ArgumentNullException("userId");
}
cancellationToken.ThrowIfCancellationRequested();
try
{
await Repository.SaveAllUserData(userId, userData, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.ErrorException("Error saving user data", ex);
throw;
}
}
/// <summary>
/// Retrieve all user data for the given user
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public IEnumerable<UserItemData> GetAllUserData(Guid userId)
{
if (userId == Guid.Empty)
{
throw new ArgumentNullException("userId");
}
return Repository.GetAllUserData(userId);
}
/// <summary>
/// Gets the user data.
/// </summary>