using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
namespace MediaBrowser.Controller.Dto
{
///
/// Class SessionInfoDtoBuilder
///
public static class SessionInfoDtoBuilder
{
///
/// Gets the session info dto.
///
/// The session.
/// SessionInfoDto.
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,
NowPlayingPositionTicks = session.NowPlayingPositionTicks,
SupportsRemoteControl = session.SupportsRemoteControl,
IsPaused = session.IsPaused,
NowViewingContext = session.NowViewingContext,
NowViewingItemIdentifier = session.NowViewingItemIdentifier,
NowViewingItemType = session.NowViewingItemType
};
if (session.NowPlayingItem != null)
{
dto.NowPlayingItem = DtoBuilder.GetBaseItemInfo(session.NowPlayingItem);
}
if (session.UserId.HasValue)
{
dto.UserId = session.UserId.Value.ToString("N");
}
return dto;
}
}
}