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
|
||||
// {
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace AyaNova.DataList
|
||||
{
|
||||
TKey = "FileSize",
|
||||
FieldKey = "size",
|
||||
UiFieldDataType = (int)UiFieldDataType.Integer,
|
||||
UiFieldDataType = (int)UiFieldDataType.MemorySize,
|
||||
SqlValueColumnName = "afileattachment.size"
|
||||
});
|
||||
|
||||
|
||||
@@ -468,6 +468,7 @@ namespace AyaNova.DataList
|
||||
}
|
||||
break;
|
||||
case UiFieldDataType.Enum://enums are just ints to the db, but it's a special type so the client can recognize it
|
||||
case UiFieldDataType.MemorySize://memory / file size, just a long but this type is for display formatting only
|
||||
case UiFieldDataType.Decimal:
|
||||
case UiFieldDataType.Currency:
|
||||
case UiFieldDataType.InternalId:
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace AyaNova.Biz
|
||||
_validCustomFieldTypes.Add((int)UiFieldDataType.Decimal);
|
||||
_validCustomFieldTypes.Add((int)UiFieldDataType.Integer);
|
||||
_validCustomFieldTypes.Add((int)UiFieldDataType.Bool);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace AyaNova.Biz
|
||||
Enum = 10,
|
||||
EmailAddress = 11,
|
||||
HTTP = 12,
|
||||
InternalId = 13
|
||||
InternalId = 13,
|
||||
MemorySize = 14//this is so client can convert what would normally be an Integer type to human readable file / ram size value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user