mirror of
https://github.com/Readarr/Readarr
synced 2025-12-28 03:09:38 +01:00
Simplify ManualImportModule null check
Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
parent
ff40d82ef1
commit
3101544484
2 changed files with 28 additions and 8 deletions
|
|
@ -47,15 +47,11 @@ private List<ManualImportResource> GetMediaFiles()
|
|||
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 @@ public static int GetIntegerQueryParameter(this Request request, string paramete
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue