Skip to content

Commit da68235

Browse files
committed
2 parents 1da7395 + 335024a commit da68235

166 files changed

Lines changed: 196987 additions & 2309 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/databases/wide-world-importers/wwi-app/Controllers/FrontEndViewsController.cs renamed to samples/databases/wide-world-importers/wwi-app/Controllers/FrontEndController.Static.cs

File renamed without changes.

samples/databases/wide-world-importers/wwi-app/Controllers/ODataController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
using Belgrade.SqlClient;
1+
using Belgrade.SqlClient;
32
using Microsoft.AspNetCore.Authorization;
43
using Microsoft.AspNetCore.Mvc;
54
using MsSql.RestApi;
@@ -20,7 +19,7 @@ public ODataController(ICommand sqlCommandService)
2019
}
2120

2221

23-
TableSpec salesorders = new TableSpec(schema: "WebApi", table: "SalesOrders", columns: "OrderID,OrderDate,CustomerPurchaseOrderNumber,ExpectedDeliveryDate,PickingCompletedWhen,CustomerID,CustomerName,PhoneNumber,FaxNumber,WebsiteURL,DeliveryLocation,SalesPerson,SalesPersonPhone,SalesPersonEmail");
22+
TableSpec salesorders = new TableSpec("WebApi","SalesOrders", "OrderID,OrderDate,CustomerPurchaseOrderNumber,ExpectedDeliveryDate,PickingCompletedWhen,CustomerID,CustomerName,PhoneNumber,FaxNumber,WebsiteURL,DeliveryLocation,SalesPerson,SalesPersonPhone,SalesPersonEmail");
2423

2524
[HttpGet]
2625
public async Task SalesOrders(int? id)

samples/databases/wide-world-importers/wwi-app/Controllers/ODataController.tt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
var json = o["ApiModel"].ToString();
77
TableDef[] config = Newtonsoft.Json.JsonConvert.DeserializeObject<TableDef[]>(json);
88
#>
9-
109
using Belgrade.SqlClient;
1110
using Microsoft.AspNetCore.Authorization;
1211
using Microsoft.AspNetCore.Mvc;

samples/databases/wide-world-importers/wwi-app/Controllers/TableController.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public async Task SalesOrders()
2020
{
2121
await this
2222
.Table(salesorders)
23-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
2423
.Process(this.sqlQuery);
2524
}
2625

@@ -29,7 +28,6 @@ public async Task PurchaseOrders()
2928
{
3029
await this
3130
.Table(purchaseorders)
32-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
3331
.Process(this.sqlQuery);
3432
}
3533

@@ -38,7 +36,6 @@ public async Task Invoices()
3836
{
3937
await this
4038
.Table(invoices)
41-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
4239
.Process(this.sqlQuery);
4340
}
4441

@@ -47,7 +44,6 @@ public async Task CustomerTransactions()
4744
{
4845
await this
4946
.Table(customertransactions)
50-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
5147
.Process(this.sqlQuery);
5248
}
5349

@@ -56,7 +52,6 @@ public async Task SupplierTransactions()
5652
{
5753
await this
5854
.Table(suppliertransactions)
59-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
6055
.Process(this.sqlQuery);
6156
}
6257

@@ -65,7 +60,6 @@ public async Task Customers()
6560
{
6661
await this
6762
.Table(customers)
68-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
6963
.Process(this.sqlQuery);
7064
}
7165

@@ -74,7 +68,6 @@ public async Task Suppliers()
7468
{
7569
await this
7670
.Table(suppliers)
77-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
7871
.Process(this.sqlQuery);
7972
}
8073

@@ -83,7 +76,6 @@ public async Task Countries()
8376
{
8477
await this
8578
.Table(countries)
86-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
8779
.Process(this.sqlQuery);
8880
}
8981

@@ -92,7 +84,6 @@ public async Task Cities()
9284
{
9385
await this
9486
.Table(cities)
95-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
9687
.Process(this.sqlQuery);
9788
}
9889

@@ -101,7 +92,6 @@ public async Task StateProvinces()
10192
{
10293
await this
10394
.Table(stateprovinces)
104-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
10595
.Process(this.sqlQuery);
10696
}
10797

@@ -110,7 +100,6 @@ public async Task StockItems()
110100
{
111101
await this
112102
.Table(stockitems)
113-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
114103
.Process(this.sqlQuery);
115104
}
116105
}

samples/databases/wide-world-importers/wwi-app/Controllers/TableController.tt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace wwi_app.Controllers
3030
{
3131
await this
3232
.Table(<#= t.Table.ToLower() #>)
33-
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
3433
.Process(this.sqlQuery);
3534
}
3635
<# } #>

samples/databases/wide-world-importers/wwi-app/wwi-app.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<EmbeddedResource Remove="wwwroot\public\**" />
1111
<None Remove="wwwroot\public\**" />
1212
</ItemGroup>
13+
<ItemGroup>
14+
<Content Remove="wwwroot\OData.tt" />
15+
</ItemGroup>
1316
<ItemGroup>
1417
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.2" />
1518
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.3" />
@@ -24,6 +27,12 @@
2427
<ItemGroup>
2528
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
2629
</ItemGroup>
30+
<ItemGroup>
31+
<EmbeddedResource Include="wwwroot\OData.tt">
32+
<Generator>TextTemplatingFileGenerator</Generator>
33+
<LastGenOutput>OData.yaml</LastGenOutput>
34+
</EmbeddedResource>
35+
</ItemGroup>
2736
<ItemGroup>
2837
<None Update="Controllers\ODataController.tt">
2938
<LastGenOutput>ODataController.cs</LastGenOutput>
@@ -55,4 +64,11 @@
5564
<Folder Include="wwwroot\lib\nvd3-new\" />
5665
<Folder Include="wwwroot\lib\nvd3\" />
5766
</ItemGroup>
67+
<ItemGroup>
68+
<Content Update="wwwroot\OData.yaml">
69+
<DesignTime>True</DesignTime>
70+
<AutoGen>True</AutoGen>
71+
<DependentUpon>OData.tt</DependentUpon>
72+
</Content>
73+
</ItemGroup>
5874
</Project>

samples/databases/wide-world-importers/wwi-app/wwwroot/OData.tt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ info:
1717
license:
1818
name: "Apache 2.0"
1919
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
20-
host: "localhost:64958"
20+
host: "localhost:64959"
2121
basePath: "/OData"
2222
tags:
2323
<# foreach(var t in config) {#>
@@ -36,21 +36,23 @@ paths:
3636
get:
3737
tags:
3838
- "<#= t.Table #>"
39-
summary: "Find information about <#= t.Table #>"
40-
description: "Multiple status values can be provided with comma separated strings"
39+
summary: "Provides information about <#= t.Table #> using OData protocol."
40+
description: "Enables querying <#= t.Table #> information using OData parameters."
4141
operationId: "<#= t.Table #>"
4242
produces:
4343
- "application/json"
4444
parameters:
4545
- name: "$select"
4646
in: "query"
47-
description: "Selecting the properties that should be returned by service"
47+
description: "Selecting the <#= t.Table #> properties that should be returned by service."
4848
required: false
4949
type: "array"
5050
items:
5151
type: "string"
52-
enum:<# foreach(var c in t.ODataColumns.Split(',')) {#>
53-
- "<#= c #>"<# } #>
52+
enum:
53+
<# foreach(var c in t.ODataColumns.Split(',')) {#>
54+
- "<#= c #>"
55+
<# } #>
5456
collectionFormat: "multi"
5557
- name: "$orderby"
5658
in: "query"
@@ -59,29 +61,31 @@ paths:
5961
type: "array"
6062
items:
6163
type: "string"
62-
enum:<# foreach(var c in t.ODataColumns.Split(',')) {#>
64+
enum:
65+
<# foreach(var c in t.ODataColumns.Split(',')) {#>
6366
- "<#= c #>"
6467
- "<#= c #> asc"
65-
- "<#= c #> desc"<# } #>
68+
- "<#= c #> desc"
69+
<# } #>
6670
collectionFormat: "multi"
6771
- name: "$top"
6872
in: "query"
69-
description: "Selecting the properties that should be returned by service"
73+
description: "Selecting the <#= t.Table #> properties that should be returned by the API."
7074
required: false
7175
type: "integer"
7276
- name: "$skip"
7377
in: "query"
74-
description: "Selecting the properties that should be returned by service"
78+
description: "Specify number of <#= t.Table #> records that should be skipped."
7579
required: false
7680
type: "integer"
7781
- name: "$apply"
7882
in: "query"
79-
description: "aggregation function that should be applied on the results"
83+
description: "Aggregation function that should be applied on the results."
8084
required: false
8185
type: "string"
8286
- name: "$filter"
8387
in: "query"
84-
description: "Condition that returned items must satisfy"
88+
description: "Condition that returned <#= t.Table #> items must satisfy. It can contain and, or, not logical operators and lt, le, gt, ge, ne, eq relational operators."
8589
required: false
8690
type: "string"
8791
responses:
@@ -90,12 +94,13 @@ paths:
9094
400:
9195
description: "The OData request is not valid"
9296
500:
93-
description: "Cannot process request"<# } #>
97+
description: "OData service cannot process request"<# } #>
9498
<#+
9599
public class TableDef {
96100
public string Schema {get; set;}
97101
public string Table {get; set;}
98102
public string ODataColumns {get; set;}
99103
public bool IsReadOnly {get; set;}
100104
}
105+
101106
#>

0 commit comments

Comments
 (0)