1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-03-25 22:00:54 +02:00

Support validation of collections in RestController

This commit is contained in:
Robert Dailey 2024-09-03 10:19:28 -05:00
parent 039d7775ed
commit e893ca4f1c

View File

@ -70,11 +70,15 @@ namespace Sonarr.Http.REST
var skipValidate = skipAttribute?.Skip ?? false;
var skipShared = skipAttribute?.SkipShared ?? false;
if (Request.Method == "POST" || Request.Method == "PUT")
if (Request.Method is "POST" or "PUT")
{
var resourceArgs = context.ActionArguments.Values.Where(x => x.GetType() == typeof(TResource))
.Select(x => x as TResource)
.ToList();
var resourceArgs = context.ActionArguments.Values
.SelectMany(x => x switch
{
TResource single => new[] { single },
IEnumerable<TResource> multiple => multiple,
_ => Enumerable.Empty<TResource>()
});
foreach (var resource in resourceArgs)
{