From d540b6ee58177d78b7c1711027f95607ce0651aa Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 16 May 2020 14:35:18 +0000 Subject: [PATCH] --- server/AyaNova/Controllers/TagController.cs | 37 +++++++++++++++++++++ server/AyaNova/biz/TagUtil.cs | 14 ++++++++ 2 files changed, 51 insertions(+) diff --git a/server/AyaNova/Controllers/TagController.cs b/server/AyaNova/Controllers/TagController.cs index c02792f1..7f1578b9 100644 --- a/server/AyaNova/Controllers/TagController.cs +++ b/server/AyaNova/Controllers/TagController.cs @@ -146,7 +146,44 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(await TagUtil.BulkRemoveAny(ayaType, tag, ct), true)); } + /// + /// Bulk replace tags to list of object id's specified + /// + /// Required + /// Required + /// Required + /// Required + /// Number of items affected + [HttpPost("bulk-replace/{ayaType}/{tag}")] + public async Task BulkReplace([FromRoute] AyaType ayaType, [FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] List idList) + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + if (!ModelState.IsValid) + return BadRequest(new ApiErrorResponse(ModelState)); + if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + return Ok(ApiOkResponse.Response(await TagUtil.BulkReplace(ayaType, fromTag, toTag, idList, ct), true)); + } + /// + /// Bulk replace tags to all objects of type specified + /// + /// Required + /// Required + /// Required + /// Number of items affected + [HttpPost("bulk-replace-any/{ayaType}/{tag}")] + public async Task BulkReplaceAny([FromRoute] AyaType ayaType, [FromRoute] string fromTag, [FromQuery] string toTag) + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + if (!ModelState.IsValid) + return BadRequest(new ApiErrorResponse(ModelState)); + if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + return Ok(ApiOkResponse.Response(await TagUtil.BulkReplaceAny(ayaType, fromTag, toTag, ct), true)); + } }//eoc diff --git a/server/AyaNova/biz/TagUtil.cs b/server/AyaNova/biz/TagUtil.cs index 0e9dcd42..a55b3681 100644 --- a/server/AyaNova/biz/TagUtil.cs +++ b/server/AyaNova/biz/TagUtil.cs @@ -243,6 +243,20 @@ namespace AyaNova.Biz } + public static async Task BulkReplace(AyaType ayaType, string fromTag, string toTag, List idList, AyContext ct) + { + //todo iterate the object in question, open and update and save each one through it's biz object interface so rules etc are all maintained + //not sure if should update locked or read only objects, probably not I guess as it should only do whatever was done in interface + + throw new System.NotImplementedException("NOT IMPLEMENTED YET"); + } + + public static async Task BulkReplaceAny(AyaType ayaType, string fromTag, string toTag, AyContext ct) + { + throw new System.NotImplementedException("NOT IMPLEMENTED YET"); + } + + }//eoc