(feature): patch request model

This commit is contained in:
Maksym Sadovnychyy 2024-11-26 22:15:25 +01:00
parent 6153963f87
commit d839722782
3 changed files with 30 additions and 2 deletions

View File

@ -0,0 +1,12 @@
using System.Reflection;
using MaksIT.Core.Webapi.Models;
namespace MaksIT.Core.Abstractions.Webapi;
public abstract class PatchRequestModelBase : RequestModelBase {
public bool HasNonNullPatchField => GetType()
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(prop => prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(PatchField<>))
.Any(prop => prop.GetValue(this) != null);
}

View File

@ -8,7 +8,7 @@
<!-- NuGet package metadata --> <!-- NuGet package metadata -->
<PackageId>MaksIT.Core</PackageId> <PackageId>MaksIT.Core</PackageId>
<Version>1.1.8</Version> <Version>1.1.9</Version>
<Authors>Maksym Sadovnychyy</Authors> <Authors>Maksym Sadovnychyy</Authors>
<Company>MAKS-IT</Company> <Company>MAKS-IT</Company>
<Product>MaksIT.Core</Product> <Product>MaksIT.Core</Product>

View File

@ -1,8 +1,24 @@
namespace MaksIT.Core.Webapi.Models; namespace MaksIT.Core.Webapi.Models;
public enum PatchOperation { public enum PatchOperation {
/// <summary>
/// When you need to replace some field, or relpace item in collection
/// </summary>
Replace, Replace,
/// <summary>
/// When you need to set some field, or add item to collection
/// </summary>
Add, Add,
/// <summary>
/// When you need to set some field to null, or remove item from collection
/// </summary>
Remove, Remove,
Clear // for collections
/// <summary>
/// When you need to clear collection
/// </summary>
Clear
} }