From 217f7876839ad890b8a5e578a764c8bf5c96505f Mon Sep 17 00:00:00 2001 From: Daniel Bloxham Date: Wed, 23 Jun 2021 10:32:30 +0100 Subject: [PATCH] HEEDLS-470 - Refactored CourseService into CourseDataService --- .../CourseDataServiceTests.cs} | 36 +++++++++---------- .../CourseDataService.cs} | 31 ++++++++++------ .../LearningPortal/AvailableTests.cs | 2 +- .../LearningPortal/CompletedTests.cs | 2 +- .../LearningPortal/CurrentTests.cs | 24 ++++++------- .../LearningPortalControllerTests.cs | 6 ++-- .../LearningPortalController/Available.cs | 6 ++-- .../LearningPortalController/Completed.cs | 4 +-- .../LearningPortalController/Current.cs | 16 ++++----- .../LearningPortalController.cs | 6 ++-- .../Centre/DashboardController.cs | 8 ++--- DigitalLearningSolutions.Web/Startup.cs | 2 +- 12 files changed, 76 insertions(+), 67 deletions(-) rename DigitalLearningSolutions.Data.Tests/{Services/CourseServiceTests.cs => DataServices/CourseDataServiceTests.cs} (78%) rename DigitalLearningSolutions.Data/{Services/CourseService.cs => DataServices/CourseDataService.cs} (80%) diff --git a/DigitalLearningSolutions.Data.Tests/Services/CourseServiceTests.cs b/DigitalLearningSolutions.Data.Tests/DataServices/CourseDataServiceTests.cs similarity index 78% rename from DigitalLearningSolutions.Data.Tests/Services/CourseServiceTests.cs rename to DigitalLearningSolutions.Data.Tests/DataServices/CourseDataServiceTests.cs index 2390663631..e54b5eaf94 100644 --- a/DigitalLearningSolutions.Data.Tests/Services/CourseServiceTests.cs +++ b/DigitalLearningSolutions.Data.Tests/DataServices/CourseDataServiceTests.cs @@ -1,20 +1,20 @@ -namespace DigitalLearningSolutions.Data.Tests.Services +namespace DigitalLearningSolutions.Data.Tests.DataServices { using System; using System.Linq; using System.Transactions; + using DigitalLearningSolutions.Data.DataServices; using DigitalLearningSolutions.Data.Mappers; using DigitalLearningSolutions.Data.Models.Courses; - using DigitalLearningSolutions.Data.Services; using DigitalLearningSolutions.Data.Tests.TestHelpers; using FakeItEasy; using FluentAssertions; using Microsoft.Extensions.Logging; using NUnit.Framework; - public class CourseServiceTests + public class CourseDataServiceTests { - private CourseService courseService; + private CourseDataDataService courseDataService; [OneTimeSetUp] public void OneTimeSetUp() @@ -26,8 +26,8 @@ public void OneTimeSetUp() public void Setup() { var connection = ServiceTestHelper.GetDatabaseConnection(); - var logger = A.Fake>(); - courseService = new CourseService(connection, logger); + var logger = A.Fake>(); + courseDataService = new CourseDataDataService(connection, logger); } [Test] @@ -35,7 +35,7 @@ public void Get_current_courses_should_return_courses_for_candidate() { // When const int candidateId = 1; - var result = courseService.GetCurrentCourses(candidateId).ToList(); + var result = courseDataService.GetCurrentCourses(candidateId).ToList(); // Then var expectedFirstCourse = new CurrentCourse @@ -66,7 +66,7 @@ public void Get_completed_courses_should_return_courses_for_candidate() { // When const int candidateId = 1; - var result = courseService.GetCompletedCourses(candidateId).ToList(); + var result = courseDataService.GetCompletedCourses(candidateId).ToList(); // Then var expectedFirstCourse = new CompletedCourse @@ -96,7 +96,7 @@ public void Get_available_courses_should_return_courses_for_candidate() // When const int candidateId = 254480; const int centreId = 101; - var result = courseService.GetAvailableCourses(candidateId, centreId).ToList(); + var result = courseDataService.GetAvailableCourses(candidateId, centreId).ToList(); // Then var expectedFirstCourse = new AvailableCourse @@ -125,7 +125,7 @@ public void Get_available_courses_should_validate_category( // When const int candidateId = 254480; const int centreId = 101; - var result = courseService.GetAvailableCourses(candidateId, centreId).ToList(); + var result = courseDataService.GetAvailableCourses(candidateId, centreId).ToList(); // Then result[index].Category.Should().Be(expectedValidatedCategory); @@ -141,7 +141,7 @@ public void Get_available_courses_should_validate_topic( // When const int candidateId = 254480; const int centreId = 101; - var result = courseService.GetAvailableCourses(candidateId, centreId).ToList(); + var result = courseDataService.GetAvailableCourses(candidateId, centreId).ToList(); // Then result[index].Topic.Should().Be(expectedValidatedTopic); @@ -152,7 +152,7 @@ public void Get_available_courses_should_return_no_courses_if_no_centre() { // When const int candidateId = 1; - var result = courseService.GetAvailableCourses(candidateId, null).ToList(); + var result = courseDataService.GetAvailableCourses(candidateId, null).ToList(); // Then result.Should().BeEmpty(); @@ -169,8 +169,8 @@ public void Set_complete_by_date_should_update_db() using (new TransactionScope()) { // When - courseService.SetCompleteByDate(progressId, candidateId, newCompleteByDate); - var modifiedCourse = courseService.GetCurrentCourses(candidateId).ToList() + courseDataService.SetCompleteByDate(progressId, candidateId, newCompleteByDate); + var modifiedCourse = courseDataService.GetCurrentCourses(candidateId).ToList() .First(c => c.ProgressID == progressId); // Then @@ -188,8 +188,8 @@ public void Remove_current_course_should_prevent_a_course_from_being_returned() const int candidateId = 1; // When - courseService.RemoveCurrentCourse(progressId, candidateId); - var courseReturned = courseService.GetCurrentCourses(candidateId).ToList() + courseDataService.RemoveCurrentCourse(progressId, candidateId); + var courseReturned = courseDataService.GetCurrentCourses(candidateId).ToList() .Any(c => c.ProgressID == progressId); // Then @@ -201,7 +201,7 @@ public void Remove_current_course_should_prevent_a_course_from_being_returned() public void GetNumberOfActiveCoursesAtCentre_returns_expected_count() { // When - var count = courseService.GetNumberOfActiveCoursesAtCentreForCategory(2, 0); + var count = courseDataService.GetNumberOfActiveCoursesAtCentreForCategory(2, 0); // Then count.Should().Be(38); @@ -211,7 +211,7 @@ public void GetNumberOfActiveCoursesAtCentre_returns_expected_count() public void GetNumberOfActiveCoursesAtCentre_with_filtered_category_returns_expected_count() { // When - var count = courseService.GetNumberOfActiveCoursesAtCentreForCategory(2, 2); + var count = courseDataService.GetNumberOfActiveCoursesAtCentreForCategory(2, 2); // Then count.Should().Be(3); diff --git a/DigitalLearningSolutions.Data/Services/CourseService.cs b/DigitalLearningSolutions.Data/DataServices/CourseDataService.cs similarity index 80% rename from DigitalLearningSolutions.Data/Services/CourseService.cs rename to DigitalLearningSolutions.Data/DataServices/CourseDataService.cs index 3cc34fa23d..29468946d1 100644 --- a/DigitalLearningSolutions.Data/Services/CourseService.cs +++ b/DigitalLearningSolutions.Data/DataServices/CourseDataService.cs @@ -1,4 +1,4 @@ -namespace DigitalLearningSolutions.Data.Services +namespace DigitalLearningSolutions.Data.DataServices { using System; using System.Collections.Generic; @@ -7,7 +7,7 @@ using DigitalLearningSolutions.Data.Models.Courses; using Microsoft.Extensions.Logging; - public interface ICourseService + public interface ICourseDataService { IEnumerable GetCurrentCourses(int candidateId); IEnumerable GetCompletedCourses(int candidateId); @@ -18,12 +18,12 @@ public interface ICourseService int GetNumberOfActiveCoursesAtCentreForCategory(int centreId, int categoryId); } - public class CourseService : ICourseService + public class CourseDataDataService : ICourseDataService { private readonly IDbConnection connection; - private readonly ILogger logger; + private readonly ILogger logger; - public CourseService(IDbConnection connection, ILogger logger) + public CourseDataDataService(IDbConnection connection, ILogger logger) { this.connection = connection; this.logger = logger; @@ -31,18 +31,27 @@ public CourseService(IDbConnection connection, ILogger logger) public IEnumerable GetCurrentCourses(int candidateId) { - return connection.Query("GetCurrentCoursesForCandidate_V2", new { candidateId }, commandType: CommandType.StoredProcedure); + return connection.Query( + "GetCurrentCoursesForCandidate_V2", + new { candidateId }, + commandType: CommandType.StoredProcedure + ); } public IEnumerable GetCompletedCourses(int candidateId) { - return connection.Query("GetCompletedCoursesForCandidate", new { candidateId }, commandType: CommandType.StoredProcedure); + return connection.Query( + "GetCompletedCoursesForCandidate", + new { candidateId }, + commandType: CommandType.StoredProcedure + ); } public IEnumerable GetAvailableCourses(int candidateId, int? centreId) { return connection.Query( - @"GetActiveAvailableCustomisationsForCentreFiltered_V5", new { candidateId, centreId }, + @"GetActiveAvailableCustomisationsForCentreFiltered_V5", + new { candidateId, centreId }, commandType: CommandType.StoredProcedure ); } @@ -55,7 +64,7 @@ public void SetCompleteByDate(int progressId, int candidateId, DateTime? complet WHERE ProgressID = @progressId AND CandidateID = @candidateId", new { date = completeByDate, progressId, candidateId } - ); + ); if (numberOfAffectedRows < 1) { @@ -69,13 +78,13 @@ public void SetCompleteByDate(int progressId, int candidateId, DateTime? complet public void RemoveCurrentCourse(int progressId, int candidateId) { var numberOfAffectedRows = connection.Execute( - @"UPDATE Progress + @"UPDATE Progress SET RemovedDate = getUTCDate(), RemovalMethodID = 1 WHERE ProgressID = @progressId AND CandidateID = @candidateId ", - new { progressId, candidateId } + new { progressId, candidateId } ); if (numberOfAffectedRows < 1) diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/AvailableTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/AvailableTests.cs index e965ee7d67..b751e74afd 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/AvailableTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/AvailableTests.cs @@ -18,7 +18,7 @@ public void Available_action_should_return_view_result() AvailableCourseHelper.CreateDefaultAvailableCourse(), AvailableCourseHelper.CreateDefaultAvailableCourse() }; - A.CallTo(() => courseService.GetAvailableCourses(CandidateId, CentreId)).Returns(availableCourses); + A.CallTo(() => courseDataService.GetAvailableCourses(CandidateId, CentreId)).Returns(availableCourses); // When var result = controller.Available(); diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CompletedTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CompletedTests.cs index 40af66f8bc..3d44dbab64 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CompletedTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CompletedTests.cs @@ -19,7 +19,7 @@ public void Completed_action_should_return_view_result() CompletedCourseHelper.CreateDefaultCompletedCourse() }; var bannerText = "bannerText"; - A.CallTo(() => courseService.GetCompletedCourses(CandidateId)).Returns(completedCourses); + A.CallTo(() => courseDataService.GetCompletedCourses(CandidateId)).Returns(completedCourses); A.CallTo(() => centresDataService.GetBannerText(CentreId)).Returns(bannerText); // When diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs index ce65764db7..541efedfc2 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs @@ -27,7 +27,7 @@ public void Current_action_should_return_view_result() }; var bannerText = "bannerText"; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(CandidateId)).Returns(selfAssessments); A.CallTo(() => centresDataService.GetBannerText(CentreId)).Returns(bannerText); @@ -57,7 +57,7 @@ public void Trying_to_edit_complete_by_date_when_not_self_enrolled_should_return { currentCourse }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When var result = controller.SetCurrentCourseCompleteByDate(currentCourse.Id, null, null, null); @@ -78,7 +78,7 @@ public void Trying_to_edit_complete_by_date_for_non_existent_course_should_retur { CurrentCourseHelper.CreateDefaultCurrentCourse(2) }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When var result = controller.SetCurrentCourseCompleteByDate(3, null, null, null); @@ -105,7 +105,7 @@ public void Setting_a_valid_complete_by_date_should_call_the_course_service() controller.SetCurrentCourseCompleteByDate(1, newDay, newMonth, newYear, 1); // Then - A.CallTo(() => courseService.SetCompleteByDate(progressId, CandidateId, newDate)).MustHaveHappened(); + A.CallTo(() => courseDataService.SetCompleteByDate(progressId, CandidateId, newDate)).MustHaveHappened(); } [Test] @@ -118,7 +118,7 @@ public void Setting_an_empty_complete_by_date_should_call_the_course_service_wit controller.SetCurrentCourseCompleteByDate(1, 0, 0, 0, 1); // Then - A.CallTo(() => courseService.SetCompleteByDate(progressId, CandidateId, null)).MustHaveHappened(); + A.CallTo(() => courseDataService.SetCompleteByDate(progressId, CandidateId, null)).MustHaveHappened(); } [Test] @@ -138,7 +138,7 @@ public void Setting_an_invalid_complete_by_date_should_not_call_the_course_servi controller.SetCurrentCourseCompleteByDate(1, 31, 2, 2020, 1); // Then - A.CallTo(() => courseService.SetCompleteByDate(1, CandidateId, A._)).MustNotHaveHappened(); + A.CallTo(() => courseDataService.SetCompleteByDate(1, CandidateId, A._)).MustNotHaveHappened(); } [Test] @@ -168,7 +168,7 @@ public void Removing_a_current_course_should_call_the_course_service() controller.RemoveCurrentCourse(1); // Then - A.CallTo(() => courseService.RemoveCurrentCourse(1, CandidateId)).MustHaveHappened(); + A.CallTo(() => courseDataService.RemoveCurrentCourse(1, CandidateId)).MustHaveHappened(); } [Test] @@ -181,7 +181,7 @@ public void Remove_confirmation_for_a_current_course_should_show_confirmation() { currentCourse }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When var result = controller.RemoveCurrentCourseConfirmation(customisationId); @@ -200,7 +200,7 @@ public void Removing_non_existent_course_should_return_404() { CurrentCourseHelper.CreateDefaultCurrentCourse(2) }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When var result = controller.RemoveCurrentCourseConfirmation(3); @@ -222,7 +222,7 @@ public void Requesting_a_course_unlock_should_call_the_unlock_service() { CurrentCourseHelper.CreateDefaultCurrentCourse(progressId: progressId, locked: true) }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When controller.RequestUnlock(progressId); @@ -239,7 +239,7 @@ public void Requesting_unlock_for_non_existent_course_should_return_404() { CurrentCourseHelper.CreateDefaultCurrentCourse(progressId: 2, locked: true) }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When var result = controller.RequestUnlock(3); @@ -261,7 +261,7 @@ public void Requesting_unlock_for_unlocked_course_should_return_404() { CurrentCourseHelper.CreateDefaultCurrentCourse(progressId: progressId) }; - A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); + A.CallTo(() => courseDataService.GetCurrentCourses(CandidateId)).Returns(currentCourses); // When var result = controller.RequestUnlock(progressId); diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/LearningPortalControllerTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/LearningPortalControllerTests.cs index 9730cb06f7..2360946c19 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/LearningPortalControllerTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/LearningPortalControllerTests.cs @@ -16,7 +16,7 @@ public partial class LearningPortalControllerTests { private LearningPortalController controller = null!; private ICentresDataService centresDataService = null!; - private ICourseService courseService = null!; + private ICourseDataService courseDataService = null!; private ISelfAssessmentService selfAssessmentService = null!; private INotificationService notificationService = null!; private IConfiguration config = null!; @@ -30,7 +30,7 @@ public partial class LearningPortalControllerTests public void SetUp() { centresDataService = A.Fake(); - courseService = A.Fake(); + courseDataService = A.Fake(); selfAssessmentService = A.Fake(); notificationService = A.Fake(); var logger = A.Fake>(); @@ -46,7 +46,7 @@ public void SetUp() }, "mock")); controller = new LearningPortalController( centresDataService, - courseService, + courseDataService, selfAssessmentService, notificationService, logger, diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Available.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Available.cs index 35f2fd486c..5310d9ce39 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Available.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Available.cs @@ -17,7 +17,7 @@ public IActionResult Available( { sortBy ??= CourseSortByOptions.Name.PropertyName; - var availableCourses = courseService.GetAvailableCourses( + var availableCourses = courseDataService.GetAvailableCourses( User.GetCandidateIdKnownNotNull(), User.GetCentreId() ); @@ -35,7 +35,7 @@ public IActionResult Available( public IActionResult AllAvailableItems() { - var availableCourses = courseService.GetAvailableCourses( + var availableCourses = courseDataService.GetAvailableCourses( User.GetCandidateIdKnownNotNull(), User.GetCentreId() ); @@ -45,7 +45,7 @@ public IActionResult AllAvailableItems() public IActionResult EnrolOnSelfAssessment(int selfAssessmentId) { - courseService.EnrolOnSelfAssessment(selfAssessmentId, User.GetCandidateIdKnownNotNull()); + courseDataService.EnrolOnSelfAssessment(selfAssessmentId, User.GetCandidateIdKnownNotNull()); return RedirectToAction("SelfAssessment", new { selfAssessmentId }); } } diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Completed.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Completed.cs index 1e25ff6083..4e62b52da9 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Completed.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Completed.cs @@ -17,7 +17,7 @@ public IActionResult Completed( { sortBy ??= CourseSortByOptions.CompletedDate.PropertyName; - var completedCourses = courseService.GetCompletedCourses(User.GetCandidateIdKnownNotNull()); + var completedCourses = courseDataService.GetCompletedCourses(User.GetCandidateIdKnownNotNull()); var bannerText = GetBannerText(); var model = new CompletedPageViewModel( completedCourses, @@ -33,7 +33,7 @@ public IActionResult Completed( public IActionResult AllCompletedItems() { - var completedCourses = courseService.GetCompletedCourses(User.GetCandidateIdKnownNotNull()); + var completedCourses = courseDataService.GetCompletedCourses(User.GetCandidateIdKnownNotNull()); var model = new AllCompletedItemsPageViewModel(completedCourses, config); return View("Completed/AllCompletedItems", model); } diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs index e0a870b1b9..53e5f2c71b 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs @@ -21,7 +21,7 @@ public IActionResult Current( { sortBy ??= CourseSortByOptions.LastAccessed.PropertyName; - var currentCourses = courseService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); + var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); var bannerText = GetBannerText(); var selfAssessments = selfAssessmentService.GetSelfAssessmentsForCandidate(User.GetCandidateIdKnownNotNull()); @@ -39,7 +39,7 @@ public IActionResult Current( public IActionResult AllCurrentItems() { - var currentCourses = courseService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); + var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); var selfAssessment = selfAssessmentService.GetSelfAssessmentsForCandidate(User.GetCandidateIdKnownNotNull()); var model = new AllCurrentItemsPageViewModel(currentCourses, selfAssessment); @@ -52,7 +52,7 @@ public IActionResult SetCurrentCourseCompleteByDate(int id, int day, int month, { if (day == 0 && month == 0 && year == 0) { - courseService.SetCompleteByDate(progressId, User.GetCandidateIdKnownNotNull(), null); + courseDataService.SetCompleteByDate(progressId, User.GetCandidateIdKnownNotNull(), null); return RedirectToAction("Current"); } @@ -63,14 +63,14 @@ public IActionResult SetCurrentCourseCompleteByDate(int id, int day, int month, } var completeByDate = new DateTime(year, month, day); - courseService.SetCompleteByDate(progressId, User.GetCandidateIdKnownNotNull(), completeByDate); + courseDataService.SetCompleteByDate(progressId, User.GetCandidateIdKnownNotNull(), completeByDate); return RedirectToAction("Current"); } [Route("/LearningPortal/Current/CompleteBy/{id:int}")] public IActionResult SetCurrentCourseCompleteByDate(int id, int? day, int? month, int? year) { - var currentCourses = courseService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); + var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); var course = currentCourses.FirstOrDefault(c => c.Id == id); if (course == null) { @@ -101,7 +101,7 @@ public IActionResult SetCurrentCourseCompleteByDate(int id, int? day, int? month [Route("/LearningPortal/Current/Remove/{id:int}")] public IActionResult RemoveCurrentCourseConfirmation(int id) { - var currentCourses = courseService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); + var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); var course = currentCourses.FirstOrDefault(c => c.Id == id); if (course == null) { @@ -119,14 +119,14 @@ public IActionResult RemoveCurrentCourseConfirmation(int id) [HttpPost] public IActionResult RemoveCurrentCourse(int progressId) { - courseService.RemoveCurrentCourse(progressId, User.GetCandidateIdKnownNotNull()); + courseDataService.RemoveCurrentCourse(progressId, User.GetCandidateIdKnownNotNull()); return RedirectToAction("Current"); } [Route("/LearningPortal/Current/RequestUnlock/{progressId:int}")] public IActionResult RequestUnlock(int progressId) { - var currentCourses = courseService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); + var currentCourses = courseDataService.GetCurrentCourses(User.GetCandidateIdKnownNotNull()); var course = currentCourses.FirstOrDefault(c => c.ProgressID == progressId && c.PLLocked); if (course == null) { diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/LearningPortalController.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/LearningPortalController.cs index 32d3daf013..41498ec572 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/LearningPortalController.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/LearningPortalController.cs @@ -13,7 +13,7 @@ namespace DigitalLearningSolutions.Web.Controllers.LearningPortalController public partial class LearningPortalController : Controller { private readonly ICentresDataService centresDataService; - private readonly ICourseService courseService; + private readonly ICourseDataService courseDataService; private readonly ISelfAssessmentService selfAssessmentService; private readonly INotificationService notificationService; private readonly ILogger logger; @@ -22,7 +22,7 @@ public partial class LearningPortalController : Controller public LearningPortalController( ICentresDataService centresDataService, - ICourseService courseService, + ICourseDataService courseDataService, ISelfAssessmentService selfAssessmentService, INotificationService notificationService, ILogger logger, @@ -30,7 +30,7 @@ public LearningPortalController( IFilteredApiHelperService filteredApiHelperService) { this.centresDataService = centresDataService; - this.courseService = courseService; + this.courseDataService = courseDataService; this.selfAssessmentService = selfAssessmentService; this.notificationService = notificationService; this.logger = logger; diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/DashboardController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/DashboardController.cs index a46551b6c0..1b8ab81103 100644 --- a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/DashboardController.cs +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/DashboardController.cs @@ -13,20 +13,20 @@ public class DashboardController : Controller { private readonly ICentresDataService centresDataService; private readonly IUserDataService userDataService; - private readonly ICourseService courseService; + private readonly ICourseDataService courseDataService; private readonly ISupportTicketDataService ticketDataService; public DashboardController ( IUserDataService userDataService, ICentresDataService centresDataService, - ICourseService courseService, + ICourseDataService courseDataService, ISupportTicketDataService ticketDataService ) { this.userDataService = userDataService; this.centresDataService = centresDataService; - this.courseService = courseService; + this.courseDataService = courseDataService; this.ticketDataService = ticketDataService; } @@ -36,7 +36,7 @@ public IActionResult Index() var centreId = User.GetCentreId(); var centre = centresDataService.GetCentreDetailsById(centreId)!; var delegateCount = userDataService.GetNumberOfApprovedDelegatesAtCentre(centreId); - var courseCount = courseService.GetNumberOfActiveCoursesAtCentreForCategory(centreId, adminUser.CategoryId); + var courseCount = courseDataService.GetNumberOfActiveCoursesAtCentreForCategory(centreId, adminUser.CategoryId); var adminCount = userDataService.GetNumberOfActiveAdminsAtCentre(centreId); var supportTicketCount = ticketDataService.GetNumberOfUnarchivedTicketsForCentreId(centreId); diff --git a/DigitalLearningSolutions.Web/Startup.cs b/DigitalLearningSolutions.Web/Startup.cs index aafa372a5c..a15d14aa88 100644 --- a/DigitalLearningSolutions.Web/Startup.cs +++ b/DigitalLearningSolutions.Web/Startup.cs @@ -121,7 +121,7 @@ public void ConfigureServices(IServiceCollection services) // Register services. services.AddScoped(); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped();