From a092b18980fac41c0f9e5e91b3582a304e4b788f Mon Sep 17 00:00:00 2001 From: sherif-olaboye <123654949+sherif-olaboye@users.noreply.github.com> Date: Tue, 1 Jul 2025 10:24:13 +0100 Subject: [PATCH 1/2] TD-3223 Showing console '404' error when removing the delegate from activity and clicking browser back button --- .../Delegates/DelegateProgressController.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/DelegateProgressController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/DelegateProgressController.cs index b2fad6e72b..c6b70ef461 100644 --- a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/DelegateProgressController.cs +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/DelegateProgressController.cs @@ -275,10 +275,8 @@ public IActionResult ConfirmRemoveFromCourse( ) { var progress = progressService.GetDetailedCourseProgress(progressId); - if (progress == null) - { - return StatusCode((int)HttpStatusCode.Gone); - } + if (!courseService.DelegateHasCurrentProgress(progressId) || progress == null) + return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 }); var model = new RemoveFromCourseViewModel( progress, @@ -305,9 +303,7 @@ RemoveFromCourseViewModel model var progress = progressService.GetDetailedCourseProgress(progressId); if (!courseService.DelegateHasCurrentProgress(progressId) || progress == null) - { - return new NotFoundResult(); - } + return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 }); courseService.RemoveDelegateFromCourse( progress.DelegateId, From ce1d59ca6d0664e7a11739d10ae2746ceaf662df Mon Sep 17 00:00:00 2001 From: sherif-olaboye <123654949+sherif-olaboye@users.noreply.github.com> Date: Tue, 1 Jul 2025 10:54:57 +0100 Subject: [PATCH 2/2] TD-3223 Showing console '404' error when removing the delegate from activity and clicking browser back button --- .../Delegates/DelegateProgressControllerTests.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/DelegateProgressControllerTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/DelegateProgressControllerTests.cs index 4934bf16b3..d5f6b60186 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/DelegateProgressControllerTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/DelegateProgressControllerTests.cs @@ -1,7 +1,5 @@ namespace DigitalLearningSolutions.Web.Tests.Controllers.TrackingSystem.Delegates { - using System; - using System.Collections.Generic; using DigitalLearningSolutions.Data.Models; using DigitalLearningSolutions.Data.Models.Courses; using DigitalLearningSolutions.Data.Models.CustomPrompts; @@ -15,8 +13,11 @@ using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.DelegateProgress; using FakeItEasy; using FluentAssertions.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using NUnit.Framework; + using System; + using System.Collections.Generic; public class DelegateProgressControllerTests { @@ -386,7 +387,11 @@ public void Delegate_removal_for_delegate_with_no_active_progress_returns_not_fo ); // Then - result.Should().BeNotFoundResult(); + result.Should() + .BeRedirectToActionResult() + .WithActionName("StatusCode") + .WithControllerName("LearningSolutions") + .WithRouteValue("code", 410); } [Test]