public async Task<IEnumerable<CustomField>> GetCustomFieldsAsync(string resourceId)
{
if (string.IsNullOrWhiteSpace(this.Database))
{
return null;
}
if (!this.SkipValidation)
{
if (!this.Validated)
{
await this.ValidateAsync(AccessTypeEnum.Read, this.LoginId, this.Database, false).ConfigureAwait(false);
}
if (!this.HasAccess)
{
Log.Information(
$"Access to get custom fields for entity \"{this.FullyQualifiedObjectName}\" was denied to the user with Login ID {this.LoginId}");
throw new UnauthorizedException("Access is denied.");
}
}
string sql;
if (string.IsNullOrWhiteSpace(resourceId))
{
sql =
$"SELECT * FROM config.custom_field_definition_view WHERE table_name='{this.FullyQualifiedObjectName}' ORDER BY field_order;";
return await Factory.GetAsync<CustomField>(this.Database, sql).ConfigureAwait(false);
}
sql = FrapidDbServer.GetProcedureCommand
(
this.Database,
"config.get_custom_field_definition",
new[]
{
"@0",
"@1"
});
return
await
Factory.GetAsync<CustomField>(this.Database, sql, this.FullyQualifiedObjectName, resourceId)
.ConfigureAwait(false);
}