Use Guid as API parameter type where possible

This commit is contained in:
crobibero
2020-12-01 11:07:41 -07:00
parent f660969e6c
commit c083b29e29
23 changed files with 99 additions and 85 deletions

View File

@@ -538,20 +538,20 @@ namespace Emby.Server.Implementations.Channels
return _libraryManager.GetItemIds(
new InternalItemsQuery
{
IncludeItemTypes = new[] { nameof(Channel) },
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) }
}).Select(i => GetChannelFeatures(i.ToString("N", CultureInfo.InvariantCulture))).ToArray();
IncludeItemTypes = new[] {nameof(Channel)},
OrderBy = new[] {(ItemSortBy.SortName, SortOrder.Ascending)}
}).Select(i => GetChannelFeatures(i)).ToArray();
}
/// <inheritdoc />
public ChannelFeatures GetChannelFeatures(string id)
public ChannelFeatures GetChannelFeatures(Guid? id)
{
if (string.IsNullOrEmpty(id))
if (!id.HasValue)
{
throw new ArgumentNullException(nameof(id));
}
var channel = GetChannel(id);
var channel = GetChannel(id.Value);
var channelProvider = GetChannelProvider(channel);
return GetChannelFeaturesDto(channel, channelProvider, channelProvider.GetChannelFeatures());

View File

@@ -2474,6 +2474,21 @@ namespace Emby.Server.Implementations.Library
return RootFolder;
}
public BaseItem GetParentItem(Guid? parentId, Guid? userId)
{
if (parentId.HasValue)
{
return GetItemById(parentId.Value);
}
if (userId.HasValue && userId != Guid.Empty)
{
return GetUserRootFolder();
}
return RootFolder;
}
/// <inheritdoc />
public bool IsVideoFile(string path)

View File

@@ -156,8 +156,8 @@ namespace Emby.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes.ToArray(),
IncludeItemTypes = includeItemTypes.ToArray(),
Limit = query.Limit,
IncludeItemsByName = string.IsNullOrEmpty(query.ParentId),
ParentId = string.IsNullOrEmpty(query.ParentId) ? Guid.Empty : new Guid(query.ParentId),
IncludeItemsByName = query.ParentId.HasValue,
ParentId = query.ParentId ?? Guid.Empty,
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) },
Recursive = true,

View File

@@ -56,13 +56,11 @@ namespace Emby.Server.Implementations.TV
return GetResult(GetNextUpEpisodes(request, user, new[] { presentationUniqueKey }, dtoOptions), request);
}
var parentIdGuid = string.IsNullOrEmpty(request.ParentId) ? (Guid?)null : new Guid(request.ParentId);
BaseItem[] parents;
if (parentIdGuid.HasValue)
if (request.ParentId.HasValue)
{
var parent = _libraryManager.GetItemById(parentIdGuid.Value);
var parent = _libraryManager.GetItemById(request.ParentId.Value);
if (parent != null)
{