jellyfin/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2013-05-09 22:43:11 +00:00
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
namespace MediaBrowser.Controller.Dto
{
/// <summary>
/// Class SessionInfoDtoBuilder
/// </summary>
public static class SessionInfoDtoBuilder
{
/// <summary>
/// Gets the session info dto.
/// </summary>
/// <param name="session">The session.</param>
/// <returns>SessionInfoDto.</returns>
public static SessionInfoDto GetSessionInfoDto(SessionInfo session)
{
var dto = new SessionInfoDto
{
Client = session.Client,
DeviceId = session.DeviceId,
DeviceName = session.DeviceName,
Id = session.Id,
LastActivityDate = session.LastActivityDate,
2013-05-10 12:18:07 +00:00
NowPlayingPositionTicks = session.NowPlayingPositionTicks,
SupportsRemoteControl = session.SupportsRemoteControl,
IsPaused = session.IsPaused,
NowViewingContext = session.NowViewingContext,
NowViewingItemIdentifier = session.NowViewingItemIdentifier,
NowViewingItemType = session.NowViewingItemType
2013-05-09 22:43:11 +00:00
};
if (session.NowPlayingItem != null)
{
dto.NowPlayingItem = DtoBuilder.GetBaseItemInfo(session.NowPlayingItem);
}
if (session.UserId.HasValue)
{
dto.UserId = session.UserId.Value.ToString("N");
}
return dto;
}
}
}