(feature): patch request model
This commit is contained in:
parent
6153963f87
commit
d839722782
12
src/MaksIT.Core/Abstractions/Webapi/PatchRequestModelBase.cs
Normal file
12
src/MaksIT.Core/Abstractions/Webapi/PatchRequestModelBase.cs
Normal 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);
|
||||||
|
}
|
||||||
@ -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>
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user