Fix patch for direct values

This commit is contained in:
Zoe Roux 2024-01-10 19:30:30 +01:00
parent a374e23821
commit 08d9b9d950

View File

@ -24,7 +24,7 @@ using Newtonsoft.Json.Linq;
namespace Kyoo.Models; namespace Kyoo.Models;
public class Patch<T> : Dictionary<string, JObject> public class Patch<T> : Dictionary<string, JToken>
where T : class, IResource where T : class, IResource
{ {
public Guid? Id => this.GetValueOrDefault(nameof(IResource.Id))?.ToObject<Guid>(); public Guid? Id => this.GetValueOrDefault(nameof(IResource.Id))?.ToObject<Guid>();
@ -33,7 +33,7 @@ public class Patch<T> : Dictionary<string, JObject>
public T Apply(T current) public T Apply(T current)
{ {
foreach ((string property, JObject value) in this) foreach ((string property, JToken value) in this)
{ {
PropertyInfo prop = typeof(T).GetProperty( PropertyInfo prop = typeof(T).GetProperty(
property, property,