public async Task<IEnumerable<dynamic>> GetAsync(string resource, int userId, object[] resourceIds)
{
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 entity \"FlagView\" was denied to the user with Login ID {LoginId}. Resource: {Resource}, ResourceIds {ResourceIds}.", this.LoginId, resource, resourceIds);
throw new UnauthorizedException("Access is denied.");
}
}
var sql = new Sql("SELECT * FROM config.flag_view");
sql.Where("resource=@0", resource);
sql.And("user_id=@0", userId);
sql.Append("AND");
sql.In("resource_id IN (@0)", resourceIds);
return await Factory.GetAsync<dynamic>(this.Database, sql).ConfigureAwait(false);
}