diff --git a/back/src/Kyoo.Core/Views/Helper/CrudApi.cs b/back/src/Kyoo.Core/Views/Helper/CrudApi.cs
index 38b68326..4e537b69 100644
--- a/back/src/Kyoo.Core/Views/Helper/CrudApi.cs
+++ b/back/src/Kyoo.Core/Views/Helper/CrudApi.cs
@@ -202,6 +202,34 @@ namespace Kyoo.Core.Api
return await Repository.Patch(old.Id, patch.Apply);
}
+ ///
+ /// Patch
+ ///
+ ///
+ /// Edit only specified properties of an item. If the ID is specified it will be used to identify the resource.
+ /// If not, the slug will be used to identify it.
+ ///
+ /// The id or slug of the resource.
+ /// The resource to patch.
+ /// The edited resource.
+ /// The resource in the request body is invalid.
+ /// No item found with the specified ID (or slug).
+ [HttpPatch("{identifier:id}")]
+ [PartialPermission(Kind.Write)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ public async Task> Patch(Identifier identifier, [FromBody] Patch patch)
+ {
+ Guid id = await identifier.Match(
+ id => Task.FromResult(id),
+ async slug => (await Repository.Get(slug)).Id
+ );
+ if (patch.Id.HasValue && patch.Id.Value != id)
+ throw new ArgumentException("Can not edit id of a resource.");
+ return await Repository.Patch(id, patch.Apply);
+ }
+
///
/// Delete an item
///