@@ -15,6 +15,7 @@ public interface ICommonService
1515 IEnumerable < Brand > GetAllBrands ( ) ;
1616 IEnumerable < Category > GetAllCategories ( ) ;
1717 IEnumerable < Topic > GetAllTopics ( ) ;
18+ IEnumerable < ( int , string ) > GetCoreCourseCategories ( ) ;
1819 IEnumerable < ( int , string ) > GetCentreTypes ( ) ;
1920 IEnumerable < ( int , string ) > GetSelfAssessmentBrands ( bool supervised ) ;
2021 IEnumerable < ( int , string ) > GetSelfAssessmentCategories ( bool supervised ) ;
@@ -24,6 +25,7 @@ public interface ICommonService
2425 IEnumerable < ( int , string ) > GetSelfAssessments ( bool supervised ) ;
2526 IEnumerable < ( int , string ) > GetSelfAssessmentCentres ( bool supervised ) ;
2627 IEnumerable < ( int , string ) > GetCourseCentres ( ) ;
28+ IEnumerable < ( int , string ) > GetCoreCourseBrands ( ) ;
2729 IEnumerable < ( int , string ) > GetCoreCourses ( ) ;
2830 string ? GetBrandNameById ( int brandId ) ;
2931 string ? GetApplicationNameById ( int applicationId ) ;
@@ -54,7 +56,7 @@ public IEnumerable<Brand> GetBrandListForCentre(int centreId)
5456 {
5557 return connection . Query < Brand > (
5658 @"SELECT BrandID, BrandName
57- FROM Brands
59+ FROM Brands WITH (NOLOCK)
5860 WHERE (Active = 1) AND (IncludeOnLanding = 1) OR
5961 (Active = 1) AND ((OwnerOrganisationID = @centreId) OR (BrandID = 6))
6062 ORDER BY BrandName" ,
@@ -65,7 +67,7 @@ public IEnumerable<Brand> GetAllBrands()
6567 {
6668 return connection . Query < Brand > (
6769 @"SELECT BrandID, BrandName
68- FROM Brands
70+ FROM Brands WITH (NOLOCK)
6971 WHERE
7072 (Active = 1)
7173 ORDER BY BrandName"
@@ -75,7 +77,7 @@ public IEnumerable<Category> GetCategoryListForCentre(int centreId)
7577 {
7678 return connection . Query < Category > (
7779 @"SELECT CourseCategoryID, CategoryName
78- FROM CourseCategories
80+ FROM CourseCategories WITH (NOLOCK)
7981 WHERE ((CentreID = @CentreID) OR (CourseCategoryID = 1)) AND (Active = 1)
8082 ORDER BY CategoryName" ,
8183 new { centreId }
@@ -85,7 +87,7 @@ public IEnumerable<Category> GetAllCategories()
8587 {
8688 return connection . Query < Category > (
8789 @"SELECT CourseCategoryID, CategoryName
88- FROM CourseCategories
90+ FROM CourseCategories WITH (NOLOCK)
8991 WHERE (Active = 1)
9092 ORDER BY CategoryName"
9193 ) ;
@@ -94,7 +96,7 @@ public IEnumerable<Topic> GetTopicListForCentre(int centreId)
9496 {
9597 return connection . Query < Topic > (
9698 @"SELECT CourseTopicID, CourseTopic
97- FROM CourseTopics
99+ FROM CourseTopics WITH (NOLOCK)
98100 WHERE ((CentreID = @CentreID) OR (CourseTopicID = 1)) AND (Active = 1)
99101 ORDER BY CourseTopic" ,
100102 new { centreId }
@@ -104,7 +106,7 @@ public IEnumerable<Topic> GetAllTopics()
104106 {
105107 return connection . Query < Topic > (
106108 @"SELECT CourseTopicID, CourseTopic
107- FROM CourseTopics
109+ FROM CourseTopics WITH (NOLOCK)
108110 WHERE (Active = 1)
109111 ORDER BY CourseTopic"
110112 ) ;
@@ -114,7 +116,7 @@ ORDER BY CourseTopic"
114116 {
115117 return connection . Query < ( int , string ) > (
116118 @"SELECT CentreTypeID, CentreType
117- FROM CentreTypes
119+ FROM CentreTypes WITH (NOLOCK)
118120 ORDER BY CentreType"
119121 ) ;
120122 }
@@ -123,8 +125,8 @@ ORDER BY CentreType"
123125 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
124126 return connection . Query < ( int , string ) > (
125127 $@ "SELECT b.BrandID, b.BrandName
126- FROM Brands AS b INNER JOIN
127- SelfAssessments AS sa ON b.BrandID = sa.BrandID
128+ FROM Brands AS b WITH (NOLOCK) INNER JOIN
129+ SelfAssessments AS sa WITH (NOLOCK) ON b.BrandID = sa.BrandID
128130 WHERE (b.Active = 1) AND
129131 (sa.ArchivedDate IS NULL) AND (sa.[National] = 1) AND { whereClause }
130132 GROUP BY b.BrandID, b.BrandName
@@ -137,7 +139,7 @@ ORDER BY b.BrandName"
137139 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
138140 return connection . Query < ( int , string ) > (
139141 $@ "SELECT cc.CourseCategoryID, cc.CategoryName
140- FROM CourseCategories AS cc INNER JOIN
142+ FROM CourseCategories AS cc WITH (NOLOCK) INNER JOIN
141143 SelfAssessments AS sa ON cc.CourseCategoryID = sa.CategoryID
142144 WHERE (cc.Active = 1) AND (sa.ArchivedDate IS NULL) AND (sa.[National] = 1) AND { whereClause }
143145 GROUP BY cc.CourseCategoryID, cc.CategoryName
@@ -150,10 +152,10 @@ ORDER BY cc.CategoryName"
150152 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
151153 return connection . Query < ( int , string ) > (
152154 $@ "SELECT ct.CentreTypeID, ct.CentreType AS CentreTypeName
153- FROM Centres AS c INNER JOIN
154- CentreSelfAssessments AS csa ON c.CentreID = csa.CentreID INNER JOIN
155- SelfAssessments AS sa ON csa.SelfAssessmentID = sa.ID INNER JOIN
156- CentreTypes AS ct ON c.CentreTypeID = ct.CentreTypeID
155+ FROM Centres AS c WITH (NOLOCK) INNER JOIN
156+ CentreSelfAssessments AS csa WITH (NOLOCK) ON c.CentreID = csa.CentreID INNER JOIN
157+ SelfAssessments AS sa WITH (NOLOCK) ON csa.SelfAssessmentID = sa.ID INNER JOIN
158+ CentreTypes AS ct WITH (NOLOCK) ON c.CentreTypeID = ct.CentreTypeID
157159 WHERE (sa.[National] = 1) AND (sa.ArchivedDate IS NULL) AND { whereClause }
158160 GROUP BY ct.CentreTypeID, ct.CentreType
159161 ORDER BY CentreTypeName"
@@ -164,10 +166,10 @@ ORDER BY CentreTypeName"
164166 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
165167 return connection . Query < ( int , string ) > (
166168 $@ "SELECT r.RegionID AS ID, r.RegionName AS Label
167- FROM Regions AS r INNER JOIN
168- Centres AS c ON r.RegionID = c.RegionID INNER JOIN
169- CentreSelfAssessments AS csa ON c.CentreID = csa.CentreID INNER JOIN
170- SelfAssessments AS sa ON csa.SelfAssessmentID = sa.ID
169+ FROM Regions AS r WITH (NOLOCK) INNER JOIN
170+ Centres AS c WITH (NOLOCK) ON r.RegionID = c.RegionID INNER JOIN
171+ CentreSelfAssessments AS csa WITH (NOLOCK) ON c.CentreID = csa.CentreID INNER JOIN
172+ SelfAssessments AS sa WITH (NOLOCK) ON csa.SelfAssessmentID = sa.ID
171173 WHERE (sa.[National] = 1) AND (sa.ArchivedDate IS NULL) AND { whereClause }
172174 GROUP BY r.RegionID, r.RegionName
173175 ORDER BY Label"
@@ -179,7 +181,7 @@ ORDER BY Label"
179181 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
180182 return connection . Query < ( int , string ) > (
181183 $@ "SELECT ID, Name AS Label
182- FROM SelfAssessments AS sa
184+ FROM SelfAssessments AS sa WITH (NOLOCK)
183185 WHERE ([National] = 1) AND (ArchivedDate IS NULL) AND { whereClause }
184186 GROUP BY ID, Name
185187 ORDER BY Label"
@@ -191,9 +193,9 @@ ORDER BY Label"
191193 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
192194 return connection . Query < ( int , string ) > (
193195 $@ "SELECT c.CentreID AS ID, c.CentreName AS Label
194- FROM Centres AS c INNER JOIN
195- CentreSelfAssessments AS csa ON c.CentreID = csa.CentreID INNER JOIN
196- SelfAssessments AS sa ON csa.SelfAssessmentID = sa.ID
196+ FROM Centres AS c WITH (NOLOCK) INNER JOIN
197+ CentreSelfAssessments AS csa WITH (NOLOCK) ON c.CentreID = csa.CentreID INNER JOIN
198+ SelfAssessments AS sa WITH (NOLOCK) ON csa.SelfAssessmentID = sa.ID
197199 WHERE (sa.[National] = 1) AND (sa.ArchivedDate IS NULL) AND { whereClause }
198200 GROUP BY c.CentreID, c.CentreName
199201 ORDER BY Label"
@@ -311,7 +313,7 @@ public int InsertTopicAndReturnId(string topicName, int centreId)
311313 {
312314 return ( string ? ) connection . ExecuteScalar (
313315 @"SELECT BrandName
314- FROM Brands
316+ FROM Brands WITH (NOLOCK)
315317 WHERE BrandID = @brandId" ,
316318 new { brandId }
317319 ) ;
@@ -320,7 +322,7 @@ FROM Brands
320322 {
321323 return ( string ? ) connection . ExecuteScalar (
322324 @"SELECT CategoryName
323- FROM CourseCategories
325+ FROM CourseCategories WITH (NOLOCK)
324326 WHERE CourseCategoryID = @categoryId" ,
325327 new { categoryId }
326328 ) ;
@@ -329,7 +331,7 @@ FROM CourseCategories
329331 {
330332 return ( string ? ) connection . ExecuteScalar (
331333 @"SELECT CourseTopic
332- FROM CourseTopics
334+ FROM CourseTopics WITH (NOLOCK)
333335 WHERE CourseTopicID = @topicId" ,
334336 new { topicId }
335337 ) ;
@@ -338,7 +340,7 @@ FROM CourseTopics
338340 {
339341 return ( string ? ) connection . ExecuteScalar (
340342 @"SELECT CentreType
341- FROM CentreTypes
343+ FROM CentreTypes WITH (NOLOCK)
342344 WHERE CentreTypeID = @centreTypeId" ,
343345 new { centreTypeId }
344346 ) ;
@@ -369,7 +371,7 @@ IF @_MaxCandidateNumber IS Null
369371 {
370372 return connection . Query < ( int , string ) > (
371373 $@ "SELECT r.RegionID AS ID, r.RegionName AS Label
372- FROM Regions AS r
374+ FROM Regions AS r WITH (NOLOCK)
373375 ORDER BY Label"
374376 ) ;
375377 }
@@ -378,7 +380,8 @@ ORDER BY Label"
378380 {
379381 return connection . Query < ( int , string ) > (
380382 $@ "SELECT c.CentreID AS ID, c.CentreName AS Label
381- FROM Centres AS c INNER JOIN CentreApplications AS ca ON c.CentreID = ca.CentreID
383+ FROM Centres AS c WITH (NOLOCK) INNER JOIN
384+ CentreApplications AS ca WITH (NOLOCK) ON c.CentreID = ca.CentreID
382385 WHERE c.Active = 1
383386 GROUP BY c.CentreID, c.CentreName
384387 ORDER BY Label"
@@ -389,8 +392,10 @@ ORDER BY Label"
389392 {
390393 return connection . Query < ( int , string ) > (
391394 $@ "SELECT a.ApplicationID AS ID, a.ApplicationName AS Label
392- FROM Applications AS a
393- WHERE ASPMenu = 1 AND ArchivedDate IS NULL AND CoreContent = 1
395+ FROM Applications AS a WITH (NOLOCK) INNER JOIN
396+ Customisations AS cu WITH (NOLOCK) ON a.ApplicationID = cu.ApplicationID
397+ WHERE (a.ASPMenu = 1) AND (a.ArchivedDate IS NULL) AND (CoreContent = 1 OR cu.AllCentres = 1)
398+ GROUP BY a.ApplicationID, a.ApplicationName
394399 ORDER BY Label"
395400 ) ;
396401 }
@@ -399,10 +404,35 @@ ORDER BY Label"
399404 {
400405 return ( string ? ) connection . ExecuteScalar (
401406 @"SELECT ApplicationName
402- FROM Applications
407+ FROM Applications WITH (NOLOCK)
403408 WHERE ApplicationID = @applicationId" ,
404409 new { applicationId }
405410 ) ;
406411 }
412+
413+ public IEnumerable < ( int , string ) > GetCoreCourseCategories ( )
414+ {
415+ return connection . Query < ( int , string ) > (
416+ @"SELECT cc.CourseCategoryID AS ID, cc.CategoryName AS Label
417+ FROM CourseCategories AS cc WITH (NOLOCK) INNER JOIN
418+ Applications AS a WITH (NOLOCK) ON a.CourseCategoryID = cc.CourseCategoryID INNER JOIN
419+ Customisations AS cu WITH (NOLOCK) ON a.ApplicationID = cu.ApplicationID
420+ WHERE (cc.Active = 1) AND (a.CoreContent = 1 OR cu.AllCentres = 1)
421+ GROUP BY cc.CourseCategoryID, cc.CategoryName
422+ ORDER BY cc.CategoryName"
423+ ) ;
424+ }
425+ public IEnumerable < ( int , string ) > GetCoreCourseBrands ( )
426+ {
427+ return connection . Query < ( int , string ) > (
428+ @"SELECT b.BrandID, b.BrandName
429+ FROM Brands AS b WITH (NOLOCK) INNER JOIN
430+ Applications AS a WITH (NOLOCK) ON b.BrandID = a.BrandID INNER JOIN
431+ Customisations AS cu WITH (NOLOCK) ON a.ApplicationID = cu.ApplicationID
432+ WHERE (b.Active = 1) AND (a.CoreContent = 1 OR cu.AllCentres = 1)
433+ GROUP BY b.BrandID, b.BrandName
434+ ORDER BY b.BrandName"
435+ ) ;
436+ }
407437 }
408438}
0 commit comments