Beispiel #1
0
        public async Task <dynamic> GetAsync(string table, string format)
        {
            await database.OpenAsync();

            string tableLocation = table;

            if (database is NpgsqlClient)
            {
                tableLocation = $"public.{table}";
            }

            if (await database.DoesTableExistAsync(tableLocation))
            {
                var tableContent = await database.GetTableAsync(tableLocation, BlacklistedFields.ToArray());

                dynamic response = null;

                if (tableContent != null)
                {
                    response = ConvertResponse(tableContent as List <List <KeyValuePair <string, string> > >, format, Response);
                }

                if (response != null)
                {
                    return(response);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound, $"Data within table \"{tableLocation}\" not found");
                }
            }
            else
            {
                throw new HttpResponseException(HttpStatusCode.NotFound, $"Table \"{tableLocation}\" not found");
            }
        }