This commit is contained in:
@@ -465,7 +465,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <returns>No content</returns>
|
/// <returns>No content</returns>
|
||||||
[HttpPost("bulk-move")]
|
[HttpPost("bulk-move")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IActionResult> PostBulkMove([FromBody] List<long> idList, [FromBody] AyaType toType, [FromBody] long toId)
|
public async Task<IActionResult> PostBulkMove([FromBody] dtoBulkMove dt)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -473,21 +473,21 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.FileAttachment))
|
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.FileAttachment))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
if (!await BizObjectExistsInDatabase.ExistsAsync(toType, toId, ct))
|
if (!await BizObjectExistsInDatabase.ExistsAsync(dt.ToType, dt.ToId, ct))
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, null, "LT:ErrorAPI2010"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, null, "LT:ErrorAPI2010"));
|
||||||
|
|
||||||
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||||
|
|
||||||
foreach (long id in idList)
|
foreach (long id in dt.IdList)
|
||||||
{
|
{
|
||||||
var dbObject = await ct.FileAttachment.FirstOrDefaultAsync(z => z.Id == id);
|
var dbObject = await ct.FileAttachment.FirstOrDefaultAsync(z => z.Id == id);
|
||||||
if (dbObject == null)
|
if (dbObject == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//do the move
|
//do the move
|
||||||
var msg = $"{dbObject.DisplayFileName} moved from {dbObject.AttachToObjectType}-{dbObject.AttachToObjectId} to {toType}-{toId} ";
|
var msg = $"{dbObject.DisplayFileName} moved from {dbObject.AttachToObjectType}-{dbObject.AttachToObjectId} to {dt.ToType}-{dt.ToId} ";
|
||||||
dbObject.AttachToObjectId = toId;
|
dbObject.AttachToObjectId = dt.ToId;
|
||||||
dbObject.AttachToObjectType = toType;
|
dbObject.AttachToObjectType = dt.ToType;
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
//Event log process move
|
//Event log process move
|
||||||
@@ -497,6 +497,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class dtoBulkMove
|
||||||
|
{
|
||||||
|
public List<long> IdList { get; set; }
|
||||||
|
public AyaType ToType { get; set; }
|
||||||
|
public long ToId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Download a file attachment
|
/// Download a file attachment
|
||||||
|
|||||||
Reference in New Issue
Block a user