@@ -15,14 +15,20 @@ 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 ) ;
2122 IEnumerable < ( int , string ) > GetSelfAssessmentCentreTypes ( bool supervised ) ;
2223 IEnumerable < ( int , string ) > GetSelfAssessmentRegions ( bool supervised ) ;
24+ IEnumerable < ( int , string ) > GetAllRegions ( ) ;
2325 IEnumerable < ( int , string ) > GetSelfAssessments ( bool supervised ) ;
2426 IEnumerable < ( int , string ) > GetSelfAssessmentCentres ( bool supervised ) ;
27+ IEnumerable < ( int , string ) > GetCourseCentres ( ) ;
28+ IEnumerable < ( int , string ) > GetCoreCourseBrands ( ) ;
29+ IEnumerable < ( int , string ) > GetCoreCourses ( ) ;
2530 string ? GetBrandNameById ( int brandId ) ;
31+ string ? GetApplicationNameById ( int applicationId ) ;
2632 string ? GetCategoryNameById ( int categoryId ) ;
2733 string ? GetTopicNameById ( int topicId ) ;
2834 string ? GenerateCandidateNumber ( string firstName , string lastName ) ;
@@ -50,7 +56,7 @@ public IEnumerable<Brand> GetBrandListForCentre(int centreId)
5056 {
5157 return connection . Query < Brand > (
5258 @"SELECT BrandID, BrandName
53- FROM Brands
59+ FROM Brands WITH (NOLOCK)
5460 WHERE (Active = 1) AND (IncludeOnLanding = 1) OR
5561 (Active = 1) AND ((OwnerOrganisationID = @centreId) OR (BrandID = 6))
5662 ORDER BY BrandName" ,
@@ -61,7 +67,7 @@ public IEnumerable<Brand> GetAllBrands()
6167 {
6268 return connection . Query < Brand > (
6369 @"SELECT BrandID, BrandName
64- FROM Brands
70+ FROM Brands WITH (NOLOCK)
6571 WHERE
6672 (Active = 1)
6773 ORDER BY BrandName"
@@ -71,7 +77,7 @@ public IEnumerable<Category> GetCategoryListForCentre(int centreId)
7177 {
7278 return connection . Query < Category > (
7379 @"SELECT CourseCategoryID, CategoryName
74- FROM CourseCategories
80+ FROM CourseCategories WITH (NOLOCK)
7581 WHERE ((CentreID = @CentreID) OR (CourseCategoryID = 1)) AND (Active = 1)
7682 ORDER BY CategoryName" ,
7783 new { centreId }
@@ -81,7 +87,7 @@ public IEnumerable<Category> GetAllCategories()
8187 {
8288 return connection . Query < Category > (
8389 @"SELECT CourseCategoryID, CategoryName
84- FROM CourseCategories
90+ FROM CourseCategories WITH (NOLOCK)
8591 WHERE (Active = 1)
8692 ORDER BY CategoryName"
8793 ) ;
@@ -90,7 +96,7 @@ public IEnumerable<Topic> GetTopicListForCentre(int centreId)
9096 {
9197 return connection . Query < Topic > (
9298 @"SELECT CourseTopicID, CourseTopic
93- FROM CourseTopics
99+ FROM CourseTopics WITH (NOLOCK)
94100 WHERE ((CentreID = @CentreID) OR (CourseTopicID = 1)) AND (Active = 1)
95101 ORDER BY CourseTopic" ,
96102 new { centreId }
@@ -100,7 +106,7 @@ public IEnumerable<Topic> GetAllTopics()
100106 {
101107 return connection . Query < Topic > (
102108 @"SELECT CourseTopicID, CourseTopic
103- FROM CourseTopics
109+ FROM CourseTopics WITH (NOLOCK)
104110 WHERE (Active = 1)
105111 ORDER BY CourseTopic"
106112 ) ;
@@ -110,7 +116,7 @@ ORDER BY CourseTopic"
110116 {
111117 return connection . Query < ( int , string ) > (
112118 @"SELECT CentreTypeID, CentreType
113- FROM CentreTypes
119+ FROM CentreTypes WITH (NOLOCK)
114120 ORDER BY CentreType"
115121 ) ;
116122 }
@@ -119,8 +125,8 @@ ORDER BY CentreType"
119125 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
120126 return connection . Query < ( int , string ) > (
121127 $@ "SELECT b.BrandID, b.BrandName
122- FROM Brands AS b INNER JOIN
123- 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
124130 WHERE (b.Active = 1) AND
125131 (sa.ArchivedDate IS NULL) AND (sa.[National] = 1) AND { whereClause }
126132 GROUP BY b.BrandID, b.BrandName
@@ -133,7 +139,7 @@ ORDER BY b.BrandName"
133139 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
134140 return connection . Query < ( int , string ) > (
135141 $@ "SELECT cc.CourseCategoryID, cc.CategoryName
136- FROM CourseCategories AS cc INNER JOIN
142+ FROM CourseCategories AS cc WITH (NOLOCK) INNER JOIN
137143 SelfAssessments AS sa ON cc.CourseCategoryID = sa.CategoryID
138144 WHERE (cc.Active = 1) AND (sa.ArchivedDate IS NULL) AND (sa.[National] = 1) AND { whereClause }
139145 GROUP BY cc.CourseCategoryID, cc.CategoryName
@@ -146,10 +152,10 @@ ORDER BY cc.CategoryName"
146152 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
147153 return connection . Query < ( int , string ) > (
148154 $@ "SELECT ct.CentreTypeID, ct.CentreType AS CentreTypeName
149- FROM Centres AS c INNER JOIN
150- CentreSelfAssessments AS csa ON c.CentreID = csa.CentreID INNER JOIN
151- SelfAssessments AS sa ON csa.SelfAssessmentID = sa.ID INNER JOIN
152- 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
153159 WHERE (sa.[National] = 1) AND (sa.ArchivedDate IS NULL) AND { whereClause }
154160 GROUP BY ct.CentreTypeID, ct.CentreType
155161 ORDER BY CentreTypeName"
@@ -160,10 +166,10 @@ ORDER BY CentreTypeName"
160166 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
161167 return connection . Query < ( int , string ) > (
162168 $@ "SELECT r.RegionID AS ID, r.RegionName AS Label
163- FROM Regions AS r INNER JOIN
164- Centres AS c ON r.RegionID = c.RegionID INNER JOIN
165- CentreSelfAssessments AS csa ON c.CentreID = csa.CentreID INNER JOIN
166- 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
167173 WHERE (sa.[National] = 1) AND (sa.ArchivedDate IS NULL) AND { whereClause }
168174 GROUP BY r.RegionID, r.RegionName
169175 ORDER BY Label"
@@ -175,7 +181,7 @@ ORDER BY Label"
175181 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
176182 return connection . Query < ( int , string ) > (
177183 $@ "SELECT ID, Name AS Label
178- FROM SelfAssessments AS sa
184+ FROM SelfAssessments AS sa WITH (NOLOCK)
179185 WHERE ([National] = 1) AND (ArchivedDate IS NULL) AND { whereClause }
180186 GROUP BY ID, Name
181187 ORDER BY Label"
@@ -187,9 +193,9 @@ ORDER BY Label"
187193 var whereClause = GetSelfAssessmentWhereClause ( supervised ) ;
188194 return connection . Query < ( int , string ) > (
189195 $@ "SELECT c.CentreID AS ID, c.CentreName AS Label
190- FROM Centres AS c INNER JOIN
191- CentreSelfAssessments AS csa ON c.CentreID = csa.CentreID INNER JOIN
192- 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
193199 WHERE (sa.[National] = 1) AND (sa.ArchivedDate IS NULL) AND { whereClause }
194200 GROUP BY c.CentreID, c.CentreName
195201 ORDER BY Label"
@@ -307,7 +313,7 @@ public int InsertTopicAndReturnId(string topicName, int centreId)
307313 {
308314 return ( string ? ) connection . ExecuteScalar (
309315 @"SELECT BrandName
310- FROM Brands
316+ FROM Brands WITH (NOLOCK)
311317 WHERE BrandID = @brandId" ,
312318 new { brandId }
313319 ) ;
@@ -316,7 +322,7 @@ FROM Brands
316322 {
317323 return ( string ? ) connection . ExecuteScalar (
318324 @"SELECT CategoryName
319- FROM CourseCategories
325+ FROM CourseCategories WITH (NOLOCK)
320326 WHERE CourseCategoryID = @categoryId" ,
321327 new { categoryId }
322328 ) ;
@@ -325,7 +331,7 @@ FROM CourseCategories
325331 {
326332 return ( string ? ) connection . ExecuteScalar (
327333 @"SELECT CourseTopic
328- FROM CourseTopics
334+ FROM CourseTopics WITH (NOLOCK)
329335 WHERE CourseTopicID = @topicId" ,
330336 new { topicId }
331337 ) ;
@@ -334,7 +340,7 @@ FROM CourseTopics
334340 {
335341 return ( string ? ) connection . ExecuteScalar (
336342 @"SELECT CentreType
337- FROM CentreTypes
343+ FROM CentreTypes WITH (NOLOCK)
338344 WHERE CentreTypeID = @centreTypeId" ,
339345 new { centreTypeId }
340346 ) ;
@@ -361,6 +367,72 @@ IF @_MaxCandidateNumber IS Null
361367 return candidateNumber ;
362368 }
363369
370+ public IEnumerable < ( int , string ) > GetAllRegions ( )
371+ {
372+ return connection . Query < ( int , string ) > (
373+ $@ "SELECT r.RegionID AS ID, r.RegionName AS Label
374+ FROM Regions AS r WITH (NOLOCK)
375+ ORDER BY Label"
376+ ) ;
377+ }
378+
379+ public IEnumerable < ( int , string ) > GetCourseCentres ( )
380+ {
381+ return connection . Query < ( int , string ) > (
382+ $@ "SELECT c.CentreID AS ID, c.CentreName AS Label
383+ FROM Centres AS c WITH (NOLOCK) INNER JOIN
384+ CentreApplications AS ca WITH (NOLOCK) ON c.CentreID = ca.CentreID
385+ WHERE c.Active = 1
386+ GROUP BY c.CentreID, c.CentreName
387+ ORDER BY Label"
388+ ) ;
389+ }
390+
391+ public IEnumerable < ( int , string ) > GetCoreCourses ( )
392+ {
393+ return connection . Query < ( int , string ) > (
394+ $@ "SELECT a.ApplicationID AS ID, a.ApplicationName AS Label
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
399+ ORDER BY Label"
400+ ) ;
401+ }
402+
403+ public string ? GetApplicationNameById ( int applicationId )
404+ {
405+ return ( string ? ) connection . ExecuteScalar (
406+ @"SELECT ApplicationName
407+ FROM Applications WITH (NOLOCK)
408+ WHERE ApplicationID = @applicationId" ,
409+ new { applicationId }
410+ ) ;
411+ }
364412
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+ }
365437 }
366438}
0 commit comments