11
22namespace DigitalLearningSolutions . Web . Controllers . SuperAdmin . Delegates
33{
4- using DigitalLearningSolutions . Data . DataServices ;
5- using DigitalLearningSolutions . Data . DataServices . UserDataService ;
64 using DigitalLearningSolutions . Data . Enums ;
75 using DigitalLearningSolutions . Data . Helpers ;
86 using DigitalLearningSolutions . Data . Models . SearchSortFilterPaginate ;
@@ -27,18 +25,16 @@ namespace DigitalLearningSolutions.Web.Controllers.SuperAdmin.Delegates
2725 [ SetSelectedTab ( nameof ( NavMenuTab . Admins ) ) ]
2826 public class DelegatesController : Controller
2927 {
30- private readonly IUserDataService userDataService ;
3128 private readonly ISearchSortFilterPaginateService searchSortFilterPaginateService ;
32- private readonly ICentresDataService centresDataService ;
29+ private readonly ICentresService centresService ;
3330 private readonly IUserService userService ;
34- public DelegatesController ( IUserDataService userDataService ,
35- ICentresDataService centresDataService ,
31+ public DelegatesController (
32+ ICentresService centresService ,
3633 ISearchSortFilterPaginateService searchSortFilterPaginateService ,
3734 IUserService userService
3835 )
3936 {
40- this . userDataService = userDataService ;
41- this . centresDataService = centresDataService ;
37+ this . centresService = centresService ;
4238 this . searchSortFilterPaginateService = searchSortFilterPaginateService ;
4339 this . userService = userService ;
4440 }
@@ -107,9 +103,9 @@ public IActionResult Index(
107103 }
108104 }
109105 }
110- ( var Delegates , var ResultCount ) = this . userDataService . GetAllDelegates ( Search ?? string . Empty , offSet , itemsPerPage ?? 0 , DelegateId , AccountStatus , LHLinkStatus , CentreId , AuthHelper . FailedLoginThreshold ) ;
106+ ( var Delegates , var ResultCount ) = this . userService . GetAllDelegates ( Search ?? string . Empty , offSet , itemsPerPage ?? 0 , DelegateId , AccountStatus , LHLinkStatus , CentreId , AuthHelper . FailedLoginThreshold ) ;
111107
112- var centres = centresDataService . GetAllCentres ( ) . ToList ( ) ;
108+ var centres = centresService . GetAllCentres ( ) . ToList ( ) ;
113109 centres . Insert ( 0 , ( 0 , "Any" ) ) ;
114110
115111 var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions (
@@ -183,7 +179,7 @@ public List<string> GetLHLinkStatus()
183179 [ Route ( "SuperAdmin/Delegates/{delegateId=0:int}/InactivateDelegateConfirmation" ) ]
184180 public IActionResult InactivateDelegateConfirmation ( int delegateId = 0 )
185181 {
186- var delegateEntity = userDataService . GetDelegateById ( delegateId ) ;
182+ var delegateEntity = userService . GetDelegateById ( delegateId ) ;
187183 if ( ! delegateEntity . DelegateAccount . Active )
188184 {
189185 return StatusCode ( ( int ) HttpStatusCode . Gone ) ;
@@ -219,7 +215,7 @@ public IActionResult InactivateDelegateConfirmation(ConfirmationViewModel confir
219215 TempData [ "DelegateId" ] = delegateId ;
220216 if ( confirmationViewModel . IsChecked )
221217 {
222- this . userDataService . DeactivateDelegateUser ( delegateId ) ;
218+ this . userService . DeactivateDelegateUser ( delegateId ) ;
223219 return RedirectToAction ( "Index" , "Delegates" , new { DelegateId = delegateId } ) ;
224220 }
225221 else
@@ -234,7 +230,7 @@ public IActionResult InactivateDelegateConfirmation(ConfirmationViewModel confir
234230 [ Route ( "SuperAdmin/Delegates/{delegateId=0:int}/ActivateDelegate" ) ]
235231 public IActionResult ActivateDelegate ( int delegateId = 0 )
236232 {
237- userDataService . ActivateDelegateUser ( delegateId ) ;
233+ userService . ActivateDelegateUser ( delegateId ) ;
238234 TempData [ "DelegateId" ] = delegateId ;
239235 return RedirectToAction ( "Index" , "Delegates" , new { DelegateId = delegateId } ) ;
240236 }
@@ -243,11 +239,11 @@ public IActionResult ActivateDelegate(int delegateId = 0)
243239 [ Route ( "SuperAdmin/Delegates/{delegateId=0:int}/RemoveCentreEmailConfirmation" ) ]
244240 public IActionResult RemoveCentreEmailConfirmation ( int delegateId = 0 )
245241 {
246- var delegateEntity = userDataService . GetDelegateById ( delegateId ) ;
242+ var delegateEntity = userService . GetDelegateById ( delegateId ) ;
247243
248244 if ( delegateEntity != null )
249245 {
250- var userCenterEmail = userDataService . GetCentreEmail ( delegateEntity . DelegateAccount . UserId , delegateEntity . DelegateAccount . CentreId ) ;
246+ var userCenterEmail = userService . GetCentreEmail ( delegateEntity . DelegateAccount . UserId , delegateEntity . DelegateAccount . CentreId ) ;
251247 if ( userCenterEmail == null )
252248 return StatusCode ( ( int ) HttpStatusCode . Gone ) ;
253249 }
@@ -282,10 +278,10 @@ public IActionResult RemoveCentreEmailConfirmation(ConfirmationViewModel confirm
282278 TempData [ "DelegateId" ] = delegateId ;
283279 if ( confirmationViewModel . IsChecked )
284280 {
285- var delegateEntity = userDataService . GetDelegateById ( delegateId ) ;
281+ var delegateEntity = userService . GetDelegateById ( delegateId ) ;
286282 if ( delegateEntity != null )
287283 {
288- userDataService . DeleteUserCentreDetail ( delegateEntity . DelegateAccount . UserId , delegateEntity . DelegateAccount . CentreId ) ;
284+ userService . DeleteUserCentreDetail ( delegateEntity . DelegateAccount . UserId , delegateEntity . DelegateAccount . CentreId ) ;
289285 }
290286 return RedirectToAction ( "Index" , "Delegates" , new { DelegateId = delegateId } ) ;
291287 }
@@ -303,7 +299,7 @@ public IActionResult RemoveCentreEmailConfirmation(ConfirmationViewModel confirm
303299 [ Route ( "SuperAdmin/Delegates/{delegateId=0:int}/ApproveDelegate" ) ]
304300 public IActionResult ApproveDelegate ( int delegateId = 0 )
305301 {
306- userDataService . ApproveDelegateUsers ( delegateId ) ;
302+ userService . ApproveDelegateUsers ( delegateId ) ;
307303 TempData [ "DelegateId" ] = delegateId ;
308304 return RedirectToAction ( "Index" , "Delegates" , new { DelegateId = delegateId } ) ;
309305 }
0 commit comments