mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Updated WWI Application
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Belgrade.SqlClient;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlServerRestApi;
|
||||
using MsSql.RestApi;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
@@ -18,14 +18,14 @@ namespace wwi_app.Controllers
|
||||
{
|
||||
this.sqlCmd = sqlCommandService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TableSpec salesorders = new TableSpec("WebApi","SalesOrders", "OrderID,OrderDate,CustomerPurchaseOrderNumber,ExpectedDeliveryDate,PickingCompletedWhen,CustomerID,CustomerName,PhoneNumber,FaxNumber,WebsiteURL,DeliveryLocation,SalesPerson,SalesPersonPhone,SalesPersonEmail");
|
||||
|
||||
[HttpGet]
|
||||
public async Task SalesOrders(int? id)
|
||||
{
|
||||
await this.OData(salesorders, this.sqlCmd, id: id).Process();
|
||||
await this.OData(salesorders, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -61,12 +61,12 @@ namespace wwi_app.Controllers
|
||||
}
|
||||
|
||||
|
||||
TableSpec salesorderlines = new TableSpec("WebApi","SalesOrderLines", "OrderLineID,OrderID,Description,Quantity,UnitPrice,TaxRate,ProductName,Brand,Size,ColorName,PackageTypeName");
|
||||
TableSpec salesorderlines = new TableSpec("WebApi","SalesOrderLines", "OrderLineID,OrderID,Description,Quantity,UnitPrice,TaxRate,ProductName,Brand,Size,ColorName,PackageTypeName,PickingCompletedWhen");
|
||||
|
||||
[HttpGet]
|
||||
public async Task SalesOrderLines(int? id)
|
||||
{
|
||||
await this.OData(salesorderlines, this.sqlCmd, id: id).Process();
|
||||
await this.OData(salesorderlines, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -107,7 +107,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task PurchaseOrders(int? id)
|
||||
{
|
||||
await this.OData(purchaseorders, this.sqlCmd, id: id).Process();
|
||||
await this.OData(purchaseorders, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -148,7 +148,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task PurchaseOrderLines(int? id)
|
||||
{
|
||||
await this.OData(purchaseorderlines, this.sqlCmd, id: id).Process();
|
||||
await this.OData(purchaseorderlines, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -189,7 +189,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task Invoices(int? id)
|
||||
{
|
||||
await this.OData(invoices, this.sqlCmd, id: id).Process();
|
||||
await this.OData(invoices, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -230,7 +230,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task SpecialDeals(int? id)
|
||||
{
|
||||
await this.OData(specialdeals, this.sqlCmd, id: id).Process();
|
||||
await this.OData(specialdeals, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -271,7 +271,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task CustomerTransactions(int? id)
|
||||
{
|
||||
await this.OData(customertransactions, this.sqlCmd, id: id).Process();
|
||||
await this.OData(customertransactions, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -312,7 +312,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task SupplierTransactions(int? id)
|
||||
{
|
||||
await this.OData(suppliertransactions, this.sqlCmd, id: id).Process();
|
||||
await this.OData(suppliertransactions, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -353,7 +353,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task Customers(int? id)
|
||||
{
|
||||
await this.OData(customers, this.sqlCmd, id: id).Process();
|
||||
await this.OData(customers, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -394,7 +394,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task Suppliers(int? id)
|
||||
{
|
||||
await this.OData(suppliers, this.sqlCmd, id: id).Process();
|
||||
await this.OData(suppliers, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -435,7 +435,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task Countries(int? id)
|
||||
{
|
||||
await this.OData(countries, this.sqlCmd, id: id).Process();
|
||||
await this.OData(countries, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -476,7 +476,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task Cities(int? id)
|
||||
{
|
||||
await this.OData(cities, this.sqlCmd, id: id).Process();
|
||||
await this.OData(cities, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -517,7 +517,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task StateProvinces(int? id)
|
||||
{
|
||||
await this.OData(stateprovinces, this.sqlCmd, id: id).Process();
|
||||
await this.OData(stateprovinces, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -558,7 +558,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task StockItems(int? id)
|
||||
{
|
||||
await this.OData(stockitems, this.sqlCmd, id: id).Process();
|
||||
await this.OData(stockitems, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -599,7 +599,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task PackageTypes(int? id)
|
||||
{
|
||||
await this.OData(packagetypes, this.sqlCmd, id: id).Process();
|
||||
await this.OData(packagetypes, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -640,7 +640,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task Colors(int? id)
|
||||
{
|
||||
await this.OData(colors, this.sqlCmd, id: id).Process();
|
||||
await this.OData(colors, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -681,7 +681,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task StockGroups(int? id)
|
||||
{
|
||||
await this.OData(stockgroups, this.sqlCmd, id: id).Process();
|
||||
await this.OData(stockgroups, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -722,7 +722,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task BuyingGroups(int? id)
|
||||
{
|
||||
await this.OData(buyinggroups, this.sqlCmd, id: id).Process();
|
||||
await this.OData(buyinggroups, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -763,7 +763,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task CustomerCategories(int? id)
|
||||
{
|
||||
await this.OData(customercategories, this.sqlCmd, id: id).Process();
|
||||
await this.OData(customercategories, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -804,7 +804,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task SupplierCategories(int? id)
|
||||
{
|
||||
await this.OData(suppliercategories, this.sqlCmd, id: id).Process();
|
||||
await this.OData(suppliercategories, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -845,7 +845,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task TransactionTypes(int? id)
|
||||
{
|
||||
await this.OData(transactiontypes, this.sqlCmd, id: id).Process();
|
||||
await this.OData(transactiontypes, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -886,7 +886,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task PaymentMethods(int? id)
|
||||
{
|
||||
await this.OData(paymentmethods, this.sqlCmd, id: id).Process();
|
||||
await this.OData(paymentmethods, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@@ -927,7 +927,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task DeliveryMethods(int? id)
|
||||
{
|
||||
await this.OData(deliverymethods, this.sqlCmd, id: id).Process();
|
||||
await this.OData(deliverymethods, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<#@ assembly name="Newtonsoft.Json" #>
|
||||
<#@ template language="C#" hostspecific="True" #>
|
||||
<#
|
||||
var o = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(this.Host.ResolvePath("..") + "\\appsettings.Development.json"));
|
||||
var o = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(this.Host.ResolvePath("..") + "\\appsettings.json"));
|
||||
var json = o["ApiModel"].ToString();
|
||||
TableDef[] config = Newtonsoft.Json.JsonConvert.DeserializeObject<TableDef[]>(json);
|
||||
#>
|
||||
@@ -10,7 +10,7 @@
|
||||
using Belgrade.SqlClient;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlServerRestApi;
|
||||
using MsSql.RestApi;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
@@ -26,7 +26,7 @@ namespace wwi_app.Controllers
|
||||
{
|
||||
this.sqlCmd = sqlCommandService;
|
||||
}
|
||||
|
||||
|
||||
<# foreach(var t in config) {#>
|
||||
|
||||
<# if(string.IsNullOrEmpty(t.ODataColumns)) continue; #>
|
||||
@@ -35,7 +35,7 @@ namespace wwi_app.Controllers
|
||||
[HttpGet]
|
||||
public async Task <#= t.Table #>(int? id)
|
||||
{
|
||||
await this.OData(<#= t.Table.ToLower() #>, this.sqlCmd, id: id).Process();
|
||||
await this.OData(<#= t.Table.ToLower() #>, id: id).Process(this.sqlCmd);
|
||||
}
|
||||
|
||||
<# if(!t.IsReadOnly) { #>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Belgrade.SqlClient;
|
||||
using SqlServerRestApi;
|
||||
using MsSql.RestApi;
|
||||
|
||||
namespace wwi_app.Controllers
|
||||
{
|
||||
@@ -19,99 +19,99 @@ namespace wwi_app.Controllers
|
||||
public async Task SalesOrders()
|
||||
{
|
||||
await this
|
||||
.Table(salesorders, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(salesorders)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec purchaseorders = new TableSpec("WebApi","PurchaseOrders", "OrderDate,SupplierReference,ExpectedDeliveryDate,ContactName,ContactPhone,IsOrderFinalized,PurchaseOrderID");
|
||||
public async Task PurchaseOrders()
|
||||
{
|
||||
await this
|
||||
.Table(purchaseorders, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(purchaseorders)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec invoices = new TableSpec("WebApi","Invoices", "InvoiceDate,CustomerPurchaseOrderNumber,CustomerName,SalesPersonName,ContactName,ContactPhone,SalesPersonEmail,InvoiceID");
|
||||
public async Task Invoices()
|
||||
{
|
||||
await this
|
||||
.Table(invoices, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(invoices)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec customertransactions = new TableSpec("WebApi","CustomerTransactions", "TransactionDate,TransactionAmount,IsFinalized,CustomerName,TransactionTypeName,PaymentMethodName,InvoiceDate,CustomerTransactionID");
|
||||
public async Task CustomerTransactions()
|
||||
{
|
||||
await this
|
||||
.Table(customertransactions, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(customertransactions)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec suppliertransactions = new TableSpec("WebApi","SupplierTransactions", "TransactionDate,TransactionAmount,IsFinalized,SupplierName,TransactionTypeName,PaymentMethodName,SupplierTransactionID");
|
||||
public async Task SupplierTransactions()
|
||||
{
|
||||
await this
|
||||
.Table(suppliertransactions, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(suppliertransactions)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec customers = new TableSpec("WebApi","Customers", "CustomerName,CustomerCategoryName,PhoneNumber,FaxNumber,BuyingGroupName,CustomerID");
|
||||
public async Task Customers()
|
||||
{
|
||||
await this
|
||||
.Table(customers, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(customers)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec suppliers = new TableSpec("WebApi","Suppliers", "SupplierName,SupplierCategoryName,PhoneNumber,FaxNumber,PrimaryContact,SupplierID");
|
||||
public async Task Suppliers()
|
||||
{
|
||||
await this
|
||||
.Table(suppliers, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(suppliers)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec countries = new TableSpec("WebApi","Countries", "FormalName,Subregion,Region,Continent,LatestRecordedPopulation,CountryID");
|
||||
public async Task Countries()
|
||||
{
|
||||
await this
|
||||
.Table(countries, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(countries)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec cities = new TableSpec("WebApi","Cities", "CityName,LatestRecordedPopulation,StateProvinceName,CityID");
|
||||
public async Task Cities()
|
||||
{
|
||||
await this
|
||||
.Table(cities, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(cities)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec stateprovinces = new TableSpec("WebApi","StateProvinces", "StateProvinceName,StateProvinceCode,SalesTerritory,LatestRecordedPopulation,CountryName,StateProvinceID");
|
||||
public async Task StateProvinces()
|
||||
{
|
||||
await this
|
||||
.Table(stateprovinces, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(stateprovinces)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
|
||||
private static readonly TableSpec stockitems = new TableSpec("WebApi","StockItems", "StockItemName,SupplierName,UnitPrice,TaxRate,RecommendedRetailPrice,StockItemID");
|
||||
public async Task StockItems()
|
||||
{
|
||||
await this
|
||||
.Table(stockitems, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(stockitems)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
<#@ assembly name="Newtonsoft.Json" #>
|
||||
<#@ template language="C#" hostspecific="True" #>
|
||||
<#
|
||||
var o = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(this.Host.ResolvePath("..") + "\\appsettings.Development.json"));
|
||||
var o = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(this.Host.ResolvePath("..") + "\\appsettings.json"));
|
||||
var json = o["ApiModel"].ToString();
|
||||
TableDef[] config = Newtonsoft.Json.JsonConvert.DeserializeObject<TableDef[]>(json);
|
||||
#>
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Belgrade.SqlClient;
|
||||
using SqlServerRestApi;
|
||||
using MsSql.RestApi;
|
||||
|
||||
namespace wwi_app.Controllers
|
||||
{
|
||||
@@ -29,9 +29,9 @@ namespace wwi_app.Controllers
|
||||
public async Task <#= t.Table #>()
|
||||
{
|
||||
await this
|
||||
.Table(<#= t.Table.ToLower() #>, this.sqlQuery)
|
||||
.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process();
|
||||
.Table(<#= t.Table.ToLower() #>)
|
||||
//.OnError(e => { this.Response.Body.Dispose(); throw e; })
|
||||
.Process(this.sqlQuery);
|
||||
}
|
||||
<# } #>
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlServerRestApi;
|
||||
using MsSql.RestApi;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<div class="row">
|
||||
<div id="part4" class="col-md-12">
|
||||
<h2>Number of orders per day in <strong>@User.Claims.FirstOrDefault(c => c.Type == "Territory").Value</strong> region</h2>
|
||||
<svg style="height:300px"> </svg>
|
||||
<h2>Daily sales in <strong>@User.Claims.FirstOrDefault(c => c.Type == "Territory").Value</strong> region</h2>
|
||||
<svg style="height:200px"> </svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{
|
||||
"Schema": "WebApi",
|
||||
"Table": "SalesOrderLines",
|
||||
"ODataColumns": "OrderLineID,OrderID,Description,Quantity,UnitPrice,TaxRate,ProductName,Brand,Size,ColorName,PackageTypeName"
|
||||
"ODataColumns": "OrderLineID,OrderID,Description,Quantity,UnitPrice,TaxRate,ProductName,Brand,Size,ColorName,PackageTypeName,PickingCompletedWhen"
|
||||
},
|
||||
{
|
||||
"Schema": "WebApi",
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
|
||||
<PackageReference Include="MsSql.RestApi" Version="0.3.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Sql-Server-Rest-Api" Version="0.8.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
$(() => {
|
||||
|
||||
$.ajax('/odata/Customers?$apply=(groupby(PostalCity),aggregate(CustomerID with sum as Total))&$orderby=CustomerID with sum desc&$top=5', { dataType: 'json' })
|
||||
$.ajax('/odata/Customers?$apply=groupby((PostalCity),aggregate(CustomerID with sum as Total))&$orderby=CustomerID with sum desc&$top=5', { dataType: 'json' })
|
||||
.done(data => {
|
||||
$("#part1 table tbody tr").view(data.value);
|
||||
});
|
||||
|
||||
$.ajax('/odata/SalesOrderLines?$apply=(groupby(ColorName),aggregate(Quantity mul UnitPrice with sum as Total))', { dataType: 'json' })
|
||||
$.ajax('/odata/SalesOrderLines?$apply=groupby((ColorName),aggregate(Quantity mul UnitPrice with sum as Total))', { dataType: 'json' })
|
||||
.done(data => {
|
||||
|
||||
nv.addGraph(function () {
|
||||
@@ -26,7 +26,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
$.ajax('/odata/PurchaseOrderLines?$apply=(groupby(ColorName),aggregate(OrderedOuters mul ExpectedUnitPricePerOuter with sum as Total))', { dataType: 'json' })
|
||||
$.ajax('/odata/PurchaseOrderLines?$apply=groupby((ColorName),aggregate(OrderedOuters mul ExpectedUnitPricePerOuter with sum as Total))', { dataType: 'json' })
|
||||
.done(data => {
|
||||
|
||||
nv.addGraph(function () {
|
||||
@@ -50,31 +50,31 @@
|
||||
});
|
||||
|
||||
|
||||
$.ajax('/odata/SalesOrders?$apply=(groupby(OrderDate),aggregate(OrderID%20with%20sum%20as%20Total))&$orderby=OrderDate%20desc&$filter=OrderDate lt \'2016-07-04\'', { dataType: 'json' })
|
||||
$.ajax('/odata/SalesOrderLines?$apply=groupby((PickingCompletedWhen),aggregate(Quantity mul UnitPrice with sum as Total))&$orderby=PickingCompletedWhen desc&$filter=PickingCompletedWhen ge \'2000-01-01\'', { dataType: 'json' })
|
||||
.done(data => {
|
||||
|
||||
nv.addGraph(function () {
|
||||
|
||||
var chart = nv.models.lineChart()
|
||||
.margin({ right: 100 })
|
||||
.x(function (d) { return new Date(d.OrderDate).getTime() }) //We can modify the data accessor functions...
|
||||
.y(function (d) { return d.Total }) //...in case your data is formatted differently.
|
||||
.x(function (d) { return new Date(d.PickingCompletedWhen).getTime(); }) //We can modify the data accessor functions...
|
||||
.y(function (d) { return d.Total; }) //...in case your data is formatted differently.
|
||||
.useInteractiveGuideline(true) //Tooltips which show all data points. Very nice!
|
||||
.rightAlignYAxis(true) //Let's move the y-axis to the right side.
|
||||
.height(300)
|
||||
.height(250)
|
||||
.showXAxis(true)
|
||||
.showYAxis(true)
|
||||
.showYAxis(true);
|
||||
|
||||
//Format x-axis labels with custom function.
|
||||
chart.xAxis
|
||||
.tickFormat(function (d) {
|
||||
return d3.time.format('%x')(new Date(d))
|
||||
return d3.time.format('%x')(new Date(d));
|
||||
});
|
||||
|
||||
d3.select("#part4 svg")
|
||||
.datum([{
|
||||
values: data.value,
|
||||
key: 'Number of sales orders',
|
||||
key: 'Daily sales ($)',
|
||||
color: '#2ca02c' }])
|
||||
.call(chart);
|
||||
|
||||
|
||||
+2
-2
@@ -161,8 +161,8 @@ SET NOCOUNT ON;
|
||||
depricated in future releases.
|
||||
*/
|
||||
EXEC DataLoadSimulation.DailyProcessToCreateHistory
|
||||
@StartDate = '20130101',
|
||||
@EndDate = '20130201',
|
||||
@StartDate = '20180101',
|
||||
@EndDate = '20181001',
|
||||
@AverageNumberOfCustomerOrdersPerDay = 60,
|
||||
@SaturdayPercentageOfNormalWorkDay = 25,
|
||||
@SundayPercentageOfNormalWorkDay = 0,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
CREATE VIEW [WebApi].[SalesOrderLines]
|
||||
AS
|
||||
SELECT ol.OrderLineID, ol.OrderID, ol.Description, ol.Quantity, ol.UnitPrice, ol.TaxRate,
|
||||
SELECT ol.OrderLineID, ol.OrderID, ol.Description, ol.Quantity, ol.UnitPrice, ol.TaxRate, ol.PickingCompletedWhen,
|
||||
ProductName = si.StockItemName, si.Brand, si.Size, c.ColorName, pt.PackageTypeName
|
||||
FROM Sales.OrderLines ol
|
||||
INNER JOIN Warehouse.StockItems si
|
||||
|
||||
Reference in New Issue
Block a user