From 37a0cf611816c2d37632604917fb1d86baf25306 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 16 May 2020 14:27:56 +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 08ad7554..99f36d33 100644 --- a/server/AyaNova/Controllers/TagController.cs +++ b/server/AyaNova/Controllers/TagController.cs @@ -111,6 +111,43 @@ namespace AyaNova.Api.Controllers } + /// + /// Bulk remove tags to list of object id's specified + /// + /// Required + /// Required + /// Required + /// Number of items affected + [HttpPost("bulk-remove/{ayaType}/{tag}")] + public async Task BulkRemove([FromRoute] AyaType ayaType, [FromRoute] string tag, [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.BulkRemove(ayaType, tag, idList, ct), true)); + } + + /// + /// Bulk remove tags to all objects of type specified + /// + /// Required + /// Required + /// Number of items affected + [HttpPost("bulk-remove-any/{ayaType}/{tag}")] + public async Task BulkRemoveAny([FromRoute] AyaType ayaType, [FromRoute] string tag) + { + 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.BulkRemoveAny(ayaType, tag, ct), true)); + } + diff --git a/server/AyaNova/biz/TagUtil.cs b/server/AyaNova/biz/TagUtil.cs index b31c5c62..0e9dcd42 100644 --- a/server/AyaNova/biz/TagUtil.cs +++ b/server/AyaNova/biz/TagUtil.cs @@ -229,6 +229,20 @@ namespace AyaNova.Biz } + public static async Task BulkRemove(AyaType ayaType, string tag, 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 BulkRemoveAny(AyaType ayaType, string tag, AyContext ct) + { + throw new System.NotImplementedException("NOT IMPLEMENTED YET"); + } + + }//eoc