fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
namespace MyOffice.Web.Infrastructure.Attributes;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
@@ -17,10 +18,15 @@ public class DefaultFromBodyBindingConvention : IActionModelConvention
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
if (action.Controller.Attributes.Any(a => a is DefaultFromBodyAttribute))
|
||||
if (action.Controller.Attributes.Any(x => x is DefaultFromBodyAttribute))
|
||||
{
|
||||
foreach (var parameter in action.Parameters)
|
||||
{
|
||||
if (parameter.Attributes.Any(x => x is FromQueryAttribute))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var paramType = parameter.ParameterInfo.ParameterType;
|
||||
var isSimpleType = paramType.IsPrimitive
|
||||
|| paramType.IsEnum
|
||||
@@ -28,6 +34,7 @@ public class DefaultFromBodyBindingConvention : IActionModelConvention
|
||||
|| paramType == typeof(int)
|
||||
|| paramType == typeof(Guid)
|
||||
|| paramType == typeof(DateTime)
|
||||
|| paramType == typeof(DateTime?)
|
||||
|| paramType == typeof(decimal);
|
||||
|
||||
if (!isSimpleType)
|
||||
|
||||
Reference in New Issue
Block a user