mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-09 05:40:53 +02:00
Support validation of collections in RestController
This commit is contained in:
parent
039d7775ed
commit
e893ca4f1c
1 changed files with 8 additions and 4 deletions
|
|
@ -70,11 +70,15 @@ public override void OnActionExecuting(ActionExecutingContext context)
|
|||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue