mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 15:22:42 +00:00
Simplify ManualImportModule null check
This commit is contained in:
parent
e8e4d76d73
commit
6713525757
2 changed files with 16 additions and 7 deletions
|
@ -47,15 +47,12 @@ private List<ManualImportResource> GetMediaFiles()
|
|||
var downloadId = (string)Request.Query.downloadId;
|
||||
NzbDrone.Core.Music.Artist artist = null;
|
||||
|
||||
var artistIdQuery = Request.Query.artistId;
|
||||
if (artistIdQuery.HasValue)
|
||||
{
|
||||
var artistId = Convert.ToInt32(artistIdQuery.Value);
|
||||
if (artistId > 0)
|
||||
var artistIdQuery = Request.GetNullableIntegerQueryParameter("artistId", null);
|
||||
|
||||
if (artistIdQuery.HasValue && artistIdQuery.Value > 0)
|
||||
{
|
||||
artist = _artistService.GetArtist(Convert.ToInt32(artistIdQuery.Value));
|
||||
}
|
||||
}
|
||||
|
||||
var filter = Request.GetBooleanQueryParameter("filterExistingFiles", true) ? FilterFilesType.Matched : FilterFilesType.None;
|
||||
var replaceExistingFiles = Request.GetBooleanQueryParameter("replaceExistingFiles", true);
|
||||
|
|
|
@ -78,5 +78,17 @@ public static Guid GetGuidQueryParameter(this Request request, string parameter,
|
|||
|
||||
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