From 84961acf2520bf7df3dab8c38de287a62313253d Mon Sep 17 00:00:00 2001 From: transtrike Date: Tue, 19 Jan 2021 19:34:38 +0200 Subject: Implemented HttpPatch --- src/DevHive.Web/Controllers/UserController.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/DevHive.Web/Controllers/UserController.cs') diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs index dc27cbf..7f4e80b 100644 --- a/src/DevHive.Web/Controllers/UserController.cs +++ b/src/DevHive.Web/Controllers/UserController.cs @@ -12,6 +12,8 @@ using DevHive.Services.Models.Language; using DevHive.Web.Models.Technology; using DevHive.Services.Models.Technology; using DevHive.Services.Interfaces; +using DevHive.Data.Models; +using Microsoft.AspNetCore.JsonPatch; namespace DevHive.Web.Controllers { @@ -101,6 +103,17 @@ namespace DevHive.Web.Controllers return new AcceptedResult("UpdateUser", userWebModel); } + + [HttpPatch] + public async Task Patch(Guid id, [FromBody] JsonPatchDocument jsonPatch) + { + UserServiceModel userServiceModel = await this._userService.PatchUser(id, jsonPatch); + + if (userServiceModel == null) + return new BadRequestObjectResult("Wrong patch properties"); + else + return new OkObjectResult(this._userMapper.Map(userServiceModel)); + } #endregion #region Delete -- cgit v1.2.3