Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PurchasingTP.AzureDb/PurchasingTP.AzureDb.sqlproj
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<Build Include="dbo\Functions\udf_GetRecentActivityForLogin.sql" />
<Build Include="dbo\Functions\udf_GetReadAndEditAccessOrderIdsForLogin.sql" />
<Build Include="dbo\Functions\udf_GetCommentHistoryForLogin.sql" />
<Build Include="dbo\Views\Get_NEWID.sql" />
</ItemGroup>
<ItemGroup>
<None Include="PurchasingTP.AzureDb.publish.xml" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@



-- =============================================
-- Author: Ken Taylor
-- Create date: January 20, 2017
Expand All @@ -8,9 +9,11 @@
-- Replaces vCommenthistory.--
-- Usage:
/*
select * from udf_GetCommentHistoryForLogin('bazemore', 5)
select * from udf_GetCommentHistoryForLogin('rajahn', 5)
*/
-- Modifications:
-- 20170216 by kjt: Needed to add grouping statement in order not to repeat same comment being returned than once because we added column "isAdmin" to
-- udf_GetReadAndEditAccessOrderIdsForLogin after this was initially created.
-- =============================================
CREATE FUNCTION [dbo].[udf_GetCommentHistoryForLogin]
(
Expand Down Expand Up @@ -41,11 +44,12 @@ BEGIN
dbo.OrderComments.UserId AS createdbyuserid,
dbo.OrderComments.DateCreated,
@LoginId AS access
FROM dbo.udf_GetReadAndEditAccessOrderIdsForLogin(@LoginId) access -- Returns orderIds only
FROM dbo.udf_GetReadAndEditAccessOrderIdsForLogin(@LoginId) access -- Returns orderIds AND isAdmin only
INNER JOIN dbo.OrderComments ON access.OrderId = dbo.OrderComments.OrderId
INNER JOIN dbo.Orders ON dbo.Orders.Id = dbo.OrderComments.OrderId
INNER JOIN dbo.Users ON dbo.Users.Id = dbo.OrderComments.UserId
ORDER BY dbo.OrderComments.DateCreated DESC
INNER JOIN dbo.Users ON dbo.Users.Id = dbo.OrderComments.UserId
GROUP BY access.OrderId, OrderComments.OrderId, Orders.RequestNumber, Users.FirstName, Users.LastName, OrderComments.Text, UserId, OrderComments.DateCreated
ORDER BY dbo.OrderComments.DateCreated DESC, access.OrderId, OrderComments.OrderId, Orders.RequestNumber, Users.FirstName, Users.LastName, OrderComments.Text, UserId

RETURN
END
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@



-- =============================================
-- Author: Ken Taylor
-- Create date: January 20, 2017
Expand All @@ -10,10 +11,11 @@
-- udf_GetReadAccessOrdersForLogin(@LoginId) user defined functions.
-- Usage:
/*
select * from udf_GetReadAndEditAccessOrdersForLogin('bazemore')
select * from udf_GetReadAndEditAccessOrderIdsForLogin('bazemore')
*/
-- Modifications:
-- 20170124 by kjt: Added "isadmin" as additional return table column.
-- 20170216 by kjt: Revised USAGE to execute correct stored procedure.
-- =============================================
CREATE FUNCTION [dbo].[udf_GetReadAndEditAccessOrderIdsForLogin]
(
Expand Down
4 changes: 4 additions & 0 deletions PurchasingTP.AzureDb/dbo/Views/Get_NEWID.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


CREATE VIEW dbo.Get_NEWID AS
SELECT NEWID() AS MyNewID