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] 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,