Skip to content

Commit a2360f1

Browse files
authored
Merge pull request #157 from JocaPC/master
GeoJSON example
2 parents 9bdcd4b + aeca8bd commit a2360f1

File tree

117 files changed

+7688
-1
lines changed

Some content is hidden

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

117 files changed

+7688
-1
lines changed
155 KB
Loading

media/demos/ivs-symbols.png

79.4 KB
Loading
998 KB
Loading

samples/demos/BelgradeProductCatalogDemo/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"Belgrade.Sql.Client": "0.5.2",
3+
"Belgrade.Sql.Client": "0.6.0",
44
"Microsoft.AspNetCore.Mvc": "1.0.0",
55
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
66
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
DROP TABLE IF EXISTS xtp.Product;
2+
GO
3+
DROP SCHEMA IF EXISTS xtp;
4+
GO
5+
6+
CREATE SCHEMA xtp;
7+
GO
8+
9+
CREATE TABLE xtp.Product (
10+
ProductID int IDENTITY PRIMARY KEY NONCLUSTERED,
11+
Name nvarchar(50) NOT NULL,
12+
Color nvarchar(15) NULL,
13+
Size nvarchar(5) NULL,
14+
Price money NOT NULL,
15+
Quantity int NULL,
16+
CompanyID int,
17+
Data nvarchar(4000),
18+
Tags nvarchar(4000),
19+
DateModified datetime2(0) NOT NULL DEFAULT (GETUTCDATE())
20+
) WITH (MEMORY_OPTIMIZED=ON)
21+
GO
22+
23+
DECLARE @products NVARCHAR(MAX) =
24+
N'[{"ProductID":15,"Name":"Adjustable Race","Color":"Magenta","Size":"62","Price":100.0000,"Quantity":75,"CompanyID":1,"Data":{"Type":"Part","MadeIn":"China"},"DateModified":"2016-02-11T21:27:32"},{"ProductID":16,"Name":"Bearing Ball","Color":"Magenta","Size":"62","Price":15.9900,"Quantity":90,"CompanyID":2,"Data":{"ManufacturingCost":11.672700,"Type":"Part","MadeIn":"China"},"Tags":["promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":17,"Name":"BB Ball Bearing","Color":"Magenta","Size":"62","Price":28.9900,"Quantity":80,"CompanyID":3,"Data":{"ManufacturingCost":21.162700,"Type":"Part","MadeIn":"China"},"DateModified":"2016-02-11T21:27:32"},{"ProductID":18,"Name":"Blade","Color":"Magenta","Size":"62","Price":18.0000,"Quantity":45,"CompanyID":4,"Data":{},"Tags":["new"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":19,"Name":"Sport-100 Helmet, Red","Color":"Red","Size":"72","Price":41.9900,"Quantity":38,"CompanyID":3,"Data":{"ManufacturingCost":30.652700,"Type":"Еquipment","MadeIn":"China"},"Tags":["promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":20,"Name":"Sport-100 Helmet, Black","Color":"Black","Size":"72","Price":31.4900,"Quantity":60,"CompanyID":1,"Data":{"ManufacturingCost":22.987700,"Type":"Еquipment","MadeIn":"China"},"Tags":["new","promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":21,"Name":"Mountain Bike Socks, M","Color":"White","Size":"M","Price":560.9900,"Quantity":30,"CompanyID":2,"Data":{"Type":"Clothes"},"Tags":["sales","promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":22,"Name":"Mountain Bike Socks, L","Color":"White","Size":"L","Price":120.9900,"Quantity":20,"CompanyID":3,"Data":{"ManufacturingCost":88.322700,"Type":"Clothes"},"Tags":["sales","promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":23,"Name":"Long-Sleeve Logo Jersey, XL","Color":"Multi","Size":"XL","Price":44.9900,"Quantity":60,"CompanyID":4,"Data":{"ManufacturingCost":32.842700,"Type":"Clothes"},"Tags":["sales","promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":24,"Name":"Road-650 Black, 52","Color":"Black","Size":"52","Price":704.6900,"Quantity":70,"CompanyID":5,"Data":{"Type":"Bike","MadeIn":"UK"},"DateModified":"2016-02-11T21:27:32"},{"ProductID":25,"Name":"Mountain-100 Silver, 38","Color":"Silver","Size":"38","Price":359.9900,"Quantity":45,"CompanyID":1,"Data":{"ManufacturingCost":262.792700,"Type":"Bike","MadeIn":"UK"},"Tags":["promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":26,"Name":"Road-250 Black, 48","Color":"Black","Size":"48","Price":299.0200,"Quantity":25,"CompanyID":2,"Data":{"ManufacturingCost":218.284600,"Type":"Bike","MadeIn":"UK"},"Tags":["new","promo"],"DateModified":"2016-02-11T21:27:32"},{"ProductID":27,"Name":"ML Bottom Bracket","Price":101.2400,"Quantity":50,"CompanyID":3,"Data":{"Type":"Part","MadeIn":"China"},"DateModified":"2016-02-11T21:27:32"},{"ProductID":28,"Name":"HL Bottom Bracket","Price":121.4900,"Quantity":65,"CompanyID":4,"Data":{"ManufacturingCost":88.687700,"Type":"Part","MadeIn":"China"},"DateModified":"2016-02-11T21:27:32"}]'
25+
INSERT INTO xtp.Product (ProductID, Name, Color, Size, Price, Quantity, CompanyID, Data, Tags, DateModified)
26+
SELECT ProductID, Name, Color, Size, Price, Quantity, CompanyID, Data, Tags, DateModified
27+
FROM OPENJSON (@products) WITH(
28+
ProductID int,Name nvarchar(50),Color nvarchar(15),Size nvarchar(5),Price money,Quantity int,CompanyID int,
29+
Data nvarchar(MAX) AS JSON,Tags nvarchar(MAX) AS JSON,
30+
DateModified datetime2(0)
31+
)
32+
GO
33+
34+
DROP PROCEDURE IF EXISTS xtp.InsertProductFromJson
35+
GO
36+
CREATE PROCEDURE xtp.InsertProductFromJson(@ProductJson NVARCHAR(MAX))
37+
WITH SCHEMABINDING, NATIVE_COMPILATION
38+
AS BEGIN
39+
ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english')
40+
INSERT INTO xtp.Product(Name,Color,Size,Price,Quantity,CompanyID,Data,Tags)
41+
OUTPUT INSERTED.ProductID
42+
SELECT Name,Color,Size,Price,Quantity,CompanyID,Data,Tags
43+
FROM OPENJSON(@ProductJson)
44+
WITH ( Name nvarchar(100) N'strict $."Name"',
45+
Color nvarchar(30),
46+
Size nvarchar(10),
47+
Price money N'strict $."Price"',
48+
Quantity int,
49+
CompanyID int,
50+
Data nvarchar(max) AS JSON,
51+
Tags nvarchar(max) AS JSON) as json
52+
END
53+
GO
54+
55+
DROP PROCEDURE IF EXISTS xtp.UpdateProductFromJson
56+
GO
57+
CREATE PROCEDURE xtp.UpdateProductFromJson(@ProductID int, @ProductJson NVARCHAR(MAX))
58+
AS BEGIN
59+
60+
UPDATE xtp.Product SET
61+
Name = json.Name,
62+
Color = json.Color,
63+
Size = json.Size,
64+
Price = json.Price,
65+
Quantity = json.Quantity,
66+
Data = ISNULL(json.Data, dbo.Product.Data),
67+
Tags = ISNULL(json.Tags,dbo.Product.Tags)
68+
FROM OPENJSON(@ProductJson)
69+
WITH ( Name nvarchar(100) N'strict $."Name"',
70+
Color nvarchar(30),
71+
Size nvarchar(10),
72+
Price money N'strict $."Price"',
73+
Quantity int,
74+
Data nvarchar(max) AS JSON,
75+
Tags nvarchar(max) AS JSON) as json
76+
WHERE xtp.Product.ProductID = @ProductID
77+
78+
END
79+
GO
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
DROP VIEW IF EXISTS History.Product
2+
GO
3+
DROP SCHEMA IF EXISTS History
4+
GO
5+
CREATE SCHEMA History
6+
GO
7+
8+
CREATE VIEW History.Product
9+
AS SELECT * FROM ProductCatalog.History.Product
10+
GO
11+
12+
drop function if exists dbo.diff_Product
13+
go
14+
create function dbo.diff_Product (@id int, @date datetime2(0))
15+
returns table
16+
as
17+
return (
18+
select * from ProductCatalog.dbo.diff_Product (@id, @date)
19+
)
20+
GO
21+
22+
23+
drop procedure if exists dbo.GetProducts
24+
go
25+
create procedure dbo.GetProducts as
26+
begin
27+
begin tran
28+
EXEC ProductCatalog.dbo.GetProducts
29+
commit
30+
end
31+
GO
32+
33+
drop procedure if exists dbo.GetProductsAsOf
34+
go
35+
create procedure dbo.GetProductsAsOf (@date datetime2) as
36+
begin
37+
begin tran
38+
EXEC ProductCatalog.dbo.GetProductsAsOf @date
39+
commit
40+
end
41+
GO
42+
43+
GO
44+
drop procedure if exists dbo.RestoreProduct
45+
GO
46+
create procedure dbo.RestoreProduct (@productid int, @date datetime2) as
47+
begin
48+
begin tran
49+
EXEC ProductCatalog.dbo.RestoreProduct @productid, @date
50+
commit
51+
end
52+
GO
1.12 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.xproj.user
2+
.vs/*
3+
.vscode/*
4+
bin/*
5+
obj/*
6+
*.sln
7+
*.log
8+
*.lock.json
9+
Properties/PublishProfiles/*
10+
appsettings.Development.json
11+
appsettings.Production.json
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Belgrade.SqlClient;
2+
using Microsoft.AspNetCore.Mvc;
3+
using SqlServerRestApi.Controller;
4+
using SqlServerRestApi.SQL;
5+
using System.Threading.Tasks;
6+
7+
// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
8+
namespace Register.Controllers
9+
{
10+
[Route("api/[controller]")]
11+
public class PeopleController : Controller
12+
{
13+
IQueryPipe sqlQuery = null;
14+
TableSpec tableSpec = new TableSpec("dbo.People", "name,surname,address,town");
15+
16+
public PeopleController(IQueryPipe sqlQueryService)
17+
{
18+
this.sqlQuery = sqlQueryService;
19+
}
20+
21+
/// <summary>
22+
/// Method that returns all data that will be processed by JQuery DataTables in client-side processing mode.
23+
/// </summary>
24+
/// <returns></returns>
25+
// GET api/People/All
26+
[HttpGet("All")]
27+
public async Task GetAll()
28+
{
29+
await sqlQuery.Stream("select name, surname, address, town from people for json path, root('data')", Response.Body, @"{""data"":[]");
30+
}
31+
32+
/// <summary>
33+
/// Method that process server-side processing JQuery DataTables HTTP request
34+
/// and returns data that should be shown.
35+
/// </summary>
36+
/// <returns></returns>
37+
// GET api/People
38+
[HttpGet]
39+
public async Task Get()
40+
{
41+
await this.ProcessJQueryDataTablesRequest(tableSpec, sqlQuery);
42+
}
43+
}
44+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>43dc1ae5-5622-4a21-8879-f6a3f70c812f</ProjectGuid>
10+
<RootNamespace>IVS</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
14+
</PropertyGroup>
15+
<PropertyGroup>
16+
<SchemaVersion>2.0</SchemaVersion>
17+
</PropertyGroup>
18+
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
19+
</Project>

0 commit comments

Comments
 (0)