Bulk tag ops

This commit is contained in:
2020-05-16 14:19:34 +00:00
parent c574f3722b
commit 6125717ba9
2 changed files with 8 additions and 8 deletions

View File

@@ -77,10 +77,11 @@ namespace AyaNova.Api.Controllers
/// Bulk add tags to objects
/// </summary>
/// <param name="ayaType">Required</param>
/// <param name="tagOpParams">Required</param>
/// <param name="tag">Required</param>
/// <param name="idList">Required</param>
/// <returns>Number of items affected</returns>
[HttpPost("bulk-add/{ayaType}")]
public async Task<IActionResult> BulkAdd([FromRoute] AyaType ayaType, [FromBody] TagUtil.BulkTagOpParameter tagOpParams)
[HttpPost("bulk-add/{ayaType}/{tag}")]
public async Task<IActionResult> BulkAdd([FromRoute] AyaType ayaType, [FromRoute] string tag, [FromBody] List<long> idList)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -88,7 +89,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse());
return Ok(ApiOkResponse.Response(await TagUtil.BulkAdd(ayaType, tagOpParams, ct), true));
return Ok(ApiOkResponse.Response(await TagUtil.BulkAdd(ayaType, tag, idList, ct), true));
}

View File

@@ -215,7 +215,7 @@ namespace AyaNova.Biz
//BULK OPS
//
public static async Task<long> BulkAdd(AyaType ayaType, BulkTagOpParameter tagOpParams, AyContext ct)
public static async Task<long> BulkAdd(AyaType ayaType, string tag, List<long> 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
@@ -224,9 +224,8 @@ namespace AyaNova.Biz
}
public class BulkTagOpParameter
{
public string NewTag { get; set; }
public class ObjectIdList
{
public List<long> ObjectIds { get; set; }
}