mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-02-28 02:35:46 +00:00
Simplify ManualImportModule null check
Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
@@ -47,15 +47,11 @@ namespace Readarr.Api.V1.ManualImport
|
||||
var downloadId = (string)Request.Query.downloadId;
|
||||
NzbDrone.Core.Books.Author author = null;
|
||||
|
||||
var authorIdQuery = Request.Query.authorId;
|
||||
if (authorIdQuery.HasValue)
|
||||
{
|
||||
var authorId = Convert.ToInt32(authorIdQuery.Value);
|
||||
var authorIdQuery = Request.GetNullableIntegerQueryParameter("authorId", null);
|
||||
|
||||
if (authorId > 0)
|
||||
{
|
||||
author = _authorService.GetAuthor(authorId);
|
||||
}
|
||||
if (authorIdQuery.HasValue && authorIdQuery.Value > 0)
|
||||
{
|
||||
author = _authorService.GetAuthor(Convert.ToInt32(authorIdQuery.Value));
|
||||
}
|
||||
|
||||
var filter = Request.GetBooleanQueryParameter("filterExistingFiles", true) ? FilterFilesType.Matched : FilterFilesType.None;
|
||||
|
||||
@@ -66,5 +66,29 @@ namespace Readarr.Http.Extensions
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static Guid GetGuidQueryParameter(this Request request, string parameter, Guid defaultValue = default)
|
||||
{
|
||||
var parameterValue = request.Query[parameter];
|
||||
|
||||
if (parameterValue.HasValue)
|
||||
{
|
||||
return Guid.Parse(parameterValue.Value);
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static int? GetNullableIntegerQueryParameter(this Request request, string parameter, int? defaultValue = null)
|
||||
{
|
||||
var parameterValue = request.Query[parameter];
|
||||
|
||||
if (parameterValue.HasValue)
|
||||
{
|
||||
return int.Parse(parameterValue.Value);
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user