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
// {

View File

@@ -78,7 +78,7 @@ namespace AyaNova.DataList
{
TKey = "FileSize",
FieldKey = "size",
UiFieldDataType = (int)UiFieldDataType.Integer,
UiFieldDataType = (int)UiFieldDataType.MemorySize,
SqlValueColumnName = "afileattachment.size"
});

View File

@@ -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:

View File

@@ -24,6 +24,7 @@ namespace AyaNova.Biz
_validCustomFieldTypes.Add((int)UiFieldDataType.Decimal);
_validCustomFieldTypes.Add((int)UiFieldDataType.Integer);
_validCustomFieldTypes.Add((int)UiFieldDataType.Bool);
}

View File

@@ -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
}
}