This commit is contained in:
@@ -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
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user