This commit is contained in:
2020-06-29 22:05:02 +00:00
parent 15759bef90
commit 75b51c7fda
5 changed files with 35 additions and 2 deletions

View File

@@ -164,6 +164,36 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Get parent object type and id
/// for specified attachment id
///
/// </summary>
/// <returns></returns>
[Authorize]
[HttpGet("parent/{id}")]
public async Task<IActionResult> GetParent([FromRoute] long id)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FileAttachment))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var at = await ct.FileAttachment.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync();
if (at == null)
return NotFound();
return Ok(ApiOkResponse.Response(new { id = at.AttachToObjectId, type = at.AttachToObjectType }));
}
//used to hold extra file data sent by client
// public class UploadFileData
// {