Skip to content

Commit f67895a

Browse files
JocaPCjovanpop-msft
authored andcommitted
Adding WWI WebSite views/procedures (#367)
* Added WWI Website views and procedures Added new views and procedures for WWI WebSite: 1. Views that expose main entities 2. Create, Update, and Delete procedures for WWI tables. * Added Website views/proc into sql project * Refactored Web APi procedures and views * Update DeleteStateProvince.sql * Fixing style on views Added quoted identifiers everywhere. * Added quoted identifiers on WebApi views * Removed refactor log from project * Addressing UC's comment changed INSERTED to inserted SearchForStockItems uses correct view in webApi schema * Removed unnesecary alias in SalesOrders view * Fixed bugs in SpecialDeals and Customers Added columns in customers view. Changed parameter name in SpecialDeals procedure. * Added quoted identifier_on in insert customer/supplier transactions and missing columns in purchase order lines view. * Added row-level security * Added wrapper views for some simple entities. * Added missing fields in suppliers view/procedure * Handled NULL columns and some missing columns in views. * Removed useless quoted identifier on * Changed quoted identifier on two update customer/supplier transactions stored procedures.
1 parent 54eaca0 commit f67895a

83 files changed

Lines changed: 1269 additions & 65 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-ssdt/wwi-ssdt/Application/Functions/DetermineCustomerAccess.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RETURN (SELECT 1 AS AccessResult
1010
INNER JOIN [Application].StateProvinces AS sp
1111
ON c.StateProvinceID = sp.StateProvinceID
1212
WHERE c.CityID = @CityID) + N' Sales') <> 0
13-
OR (ORIGINAL_LOGIN() = N'Website'
13+
OR ((ORIGINAL_LOGIN() = N'Website' OR ORIGINAL_LOGIN() = N'WebApi')
1414
AND EXISTS (SELECT 1
1515
FROM [Application].Cities AS c
1616
INNER JOIN [Application].StateProvinces AS sp

samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Security/Permissions.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ GRANT VIEW ANY COLUMN ENCRYPTION KEY DEFINITION TO PUBLIC;
55
GO
66
GRANT VIEW ANY COLUMN MASTER KEY DEFINITION TO PUBLIC;
77
*/
8+
9+
GO
10+
CREATE LOGIN WebApi WITH PASSWORD = 'Sp1d3rman!';
11+
GO
12+
CREATE USER WebApi FROM LOGIN WebApi;
13+
GO
14+
GRANT EXECUTE ON SCHEMA::WebApi TO WebApi;
15+
GO
16+
GRANT SELECT ON SCHEMA::WebApi TO WebApi;
17+
GO
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE SCHEMA [WebApi]
2+
AUTHORIZATION [dbo];
3+
4+
5+
6+
7+
GO
8+
EXECUTE sp_addextendedproperty @name = N'Description', @value = N'Views and stored procedures that provide the only access for the application Web API', @level0type = N'SCHEMA', @level0name = N'WebApi';
9+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteBuyingGroup](@BuyingGroupID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Sales.BuyingGroups
5+
WHERE BuyingGroupID = @BuyingGroupID
6+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteCity](@CityID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Application.Cities
5+
WHERE CityID = @CityID
6+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteColor](@ColorID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Warehouse.Colors
5+
WHERE ColorID = @ColorID
6+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteCountry](@CountryID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Application.Countries
5+
WHERE CountryID = @CountryID;
6+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteCustomer](@CustomerID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Sales.Customers
5+
WHERE CustomerID = @CustomerID;
6+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteCustomerCategory](@CustomerCategoryID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Sales.CustomerCategories
5+
WHERE CustomerCategoryID = @CustomerCategoryID
6+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE PROCEDURE [WebApi].[DeleteDeliveryMethod](@DeliveryMethodID int)
2+
WITH EXECUTE AS OWNER
3+
AS BEGIN
4+
DELETE Application.DeliveryMethods
5+
WHERE DeliveryMethodID = @DeliveryMethodID
6+
END

0 commit comments

Comments
 (0)