This commit is contained in:
2026-06-04 09:44:23 +03:00
parent 4ddab34ad1
commit 033b4fc247
29 changed files with 3661 additions and 59 deletions
@@ -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)