Async/Await TableController, mv LICENSE, fix pipeline

master
exsersewo 4 years ago
parent cbd529613c
commit fd6597a0ec
  1. 0
      LICENSE
  2. 2
      azure-pipelines.yml
  3. 4
      src/RestAPI.sln
  4. 21
      src/RestAPI/Controllers/TableController.cs

@ -36,4 +36,4 @@ steps:
platform: 'x64' platform: 'x64'
solution: '$(solution)' solution: '$(solution)'
configuration: '$(buildConfiguration)' configuration: '$(buildConfiguration)'
msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" /p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload' platform: '$(buildPlatform)'

@ -8,6 +8,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{197287CE-CDEF-4FF8-9846-EFF913496E1A}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{197287CE-CDEF-4FF8-9846-EFF913496E1A}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
..\.env.default = ..\.env.default ..\.env.default = ..\.env.default
..\azure-pipelines.yml = ..\azure-pipelines.yml
..\NuGet.config = ..\NuGet.config
EndProjectSection EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{98D984C1-F9F9-4D41-8CDA-4D87F5C0A774}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{98D984C1-F9F9-4D41-8CDA-4D87F5C0A774}"
@ -19,7 +21,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github", "Github", "{766907EE-8F38-477E-BD1D-F34EA54AC784}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github", "Github", "{766907EE-8F38-477E-BD1D-F34EA54AC784}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
..\.github\LICENSE = ..\.github\LICENSE ..\.github\LICENSE = ..\.github\LICENSE
..\.github\README = ..\.github\README ..\.github\README.md = ..\.github\README.md
EndProjectSection EndProjectSection
EndProject EndProject
Global Global

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks;
using System.Xml; using System.Xml;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@ -38,7 +39,7 @@ namespace RestAPI.Controllers
} }
} }
private dynamic ConvertResponse(List<List<KeyValuePair<string, string>>> tableContent, string format, HttpResponse Response) private static dynamic ConvertResponse(List<List<KeyValuePair<string, string>>> tableContent, string format, HttpResponse Response)
{ {
switch (format.ToLowerInvariant()) switch (format.ToLowerInvariant())
{ {
@ -46,7 +47,7 @@ namespace RestAPI.Controllers
{ {
Response.ContentType = "application/json"; Response.ContentType = "application/json";
List<dynamic> content = new List<dynamic>(); List<dynamic> content = new();
foreach (var result in tableContent) foreach (var result in tableContent)
{ {
@ -147,9 +148,9 @@ namespace RestAPI.Controllers
} }
[HttpGet("{table}.{format}")] [HttpGet("{table}.{format}")]
public dynamic Get(string table, string format) public async Task<dynamic> GetAsync(string table, string format)
{ {
database.OpenAsync().GetAwaiter().GetResult(); await database.OpenAsync();
string tableLocation = table; string tableLocation = table;
@ -158,9 +159,9 @@ namespace RestAPI.Controllers
tableLocation = $"public.{table}"; tableLocation = $"public.{table}";
} }
if (database.DoesTableExistAsync(tableLocation).GetAwaiter().GetResult()) if (await database.DoesTableExistAsync(tableLocation))
{ {
var tableContent = database.GetTableAsync(tableLocation, BlacklistedFields.ToArray()).GetAwaiter().GetResult(); var tableContent = await database.GetTableAsync(tableLocation, BlacklistedFields.ToArray());
dynamic response = null; dynamic response = null;
if (tableContent != null) if (tableContent != null)
@ -184,9 +185,9 @@ namespace RestAPI.Controllers
} }
[HttpGet("{area}/{table}.{format}")] [HttpGet("{area}/{table}.{format}")]
public dynamic Get(string area, string table, string format) public async Task<dynamic> GetAsync(string area, string table, string format)
{ {
database.OpenAsync().GetAwaiter().GetResult(); await database.OpenAsync();
string tableLocation; string tableLocation;
@ -199,9 +200,9 @@ namespace RestAPI.Controllers
tableLocation = $"{area}/{table}"; //default assumption for now tableLocation = $"{area}/{table}"; //default assumption for now
} }
if (database.DoesTableExistAsync(tableLocation).GetAwaiter().GetResult()) if (await database.DoesTableExistAsync(tableLocation))
{ {
var tableContent = database.GetTableAsync(tableLocation, BlacklistedFields.ToArray()).GetAwaiter().GetResult(); var tableContent = await database.GetTableAsync(tableLocation, BlacklistedFields.ToArray());
dynamic response = null; dynamic response = null;
if (tableContent != null) if (tableContent != null)

Loading…
Cancel
Save