Skip to content

Commit

Permalink
ER-1145 - Withdrawn application error page (#822) +semver: patch
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjensenuk authored and Deven Shah committed Oct 15, 2019
1 parent 6f878b0 commit cbc8f50
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Employer/Employer.Web/Configuration/ViewNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public class ViewNames
public const string AccessDenied = "AccessDenied";
public const string PageNotFound = "PageNotFound";
public const string BlockedEmployer = "BlockedEmployer";
public const string ApplicationWithdrawn = "ApplicationWithdrawn";
}
}
19 changes: 19 additions & 0 deletions src/Employer/Employer.Web/Controllers/ErrorController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Esfa.Recruit.Employer.Web.Configuration;
using Esfa.Recruit.Employer.Web.Configuration.Routing;
using Esfa.Recruit.Employer.Web.Exceptions;
using Esfa.Recruit.Employer.Web.RouteModel;
using Esfa.Recruit.Employer.Web.ViewModels.Error;
using Esfa.Recruit.Vacancies.Client.Domain.Exceptions;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Exceptions;
Expand Down Expand Up @@ -96,6 +97,11 @@ public IActionResult ErrorHandler()
return RedirectToRoute(RouteNames.BlockedEmployer_Get, new { EmployerAccountId = employerAccountId });
}

if(exception is ApplicationWithdrawnException withdrawnException)
{
return ApplicationWithdrawn(employerAccountId.ToString(), withdrawnException);
}

_logger.LogError(exception, "Unhandled exception on path: {route}", routeWhereExceptionOccurred);
}

Expand All @@ -115,6 +121,19 @@ private IActionResult PageNotFound()
return View(ViewNames.PageNotFound);
}

private IActionResult ApplicationWithdrawn(string employerAccountId, ApplicationWithdrawnException exception)
{
_logger.LogInformation(exception.Message);
Response.StatusCode = (int)HttpStatusCode.NotFound;
var returnLink = Url.RouteUrl(RouteNames.VacancyManage_Get, new VacancyRouteModel
{
EmployerAccountId = employerAccountId,
VacancyId = exception.VacancyId
});

return View(ViewNames.ApplicationWithdrawn, returnLink);
}

// Blocked employer url required for analytics reasons
[HttpGet("error/blocked-employer/{employerAccountId}", Name = RouteNames.BlockedEmployer_Get)]
public IActionResult BlockedEmployer(string employerAccountId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Esfa.Recruit.Vacancies.Client.Domain.Exceptions;

namespace Esfa.Recruit.Employer.Web.Exceptions
{
public class ApplicationWithdrawnException : RecruitException
{
public Guid VacancyId { get;}

public ApplicationWithdrawnException(string message, Guid vacancyId) : base(message)
{
VacancyId = vacancyId;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Esfa.Recruit.Shared.Web.ViewModels.ApplicationReview;
using Esfa.Recruit.Employer.Web.Exceptions;

namespace Esfa.Recruit.Employer.Web.Orchestrators
{
Expand All @@ -25,7 +26,7 @@ public async Task<ApplicationReviewViewModel> GetApplicationReviewViewModelAsync
var applicationReview = await Utility.GetAuthorisedApplicationReviewAsync(_vacancyClient, rm);

if (applicationReview.IsWithdrawn)
throw new Exception($"Application has been withdrawn. ApplicationReviewId:{applicationReview.Id}");
throw new ApplicationWithdrawnException($"Application has been withdrawn. ApplicationReviewId:{applicationReview.Id}", rm.VacancyId);

return applicationReview.ToViewModel();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Employer/Employer.Web/Views/Error/ApplicationWithdrawn.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@model string

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl govuk-!-margin-bottom-0">This application has been withdrawn by the candidate</h1>

<p class="govuk-body govuk-!-margin-top-3">
<a href="@Model" class="govuk-button">Back to vacancy</a>
</p>
</div>
</div>
1 change: 1 addition & 0 deletions src/Provider/Provider.Web/Configuration/ViewNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public class ViewNames
public const string VacancyPreview = "VacancyPreview";
public const string CloseVacancyView = "Close";
public const string Training = "Training";
public const string ApplicationWithdrawn = "ApplicationWithdrawn";
}
}
19 changes: 19 additions & 0 deletions src/Provider/Provider.Web/Controllers/ErrorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Net;
using System.Text;
using Esfa.Recruit.Proivder.Web.Exceptions;
using Esfa.Recruit.Provider.Web.Configuration;
using Esfa.Recruit.Provider.Web.Configuration.Routing;
using Esfa.Recruit.Provider.Web.Exceptions;
Expand Down Expand Up @@ -110,6 +111,11 @@ public IActionResult ErrorHandler()
return MissingPermissions(long.Parse((string)ukprn));
}

if (exception is ApplicationWithdrawnException withdrawnException)
{
return ApplicationWithdrawn(long.Parse((string)ukprn), withdrawnException);
}

_logger.LogError(exception, "Unhandled exception on path: {route}", routeWhereExceptionOccurred);
}

Expand Down Expand Up @@ -188,6 +194,19 @@ private IActionResult PageNotFound()
return View(ViewNames.PageNotFound);
}

private IActionResult ApplicationWithdrawn(long ukprn, ApplicationWithdrawnException exception)
{
_logger.LogInformation(exception.Message);
Response.StatusCode = (int)HttpStatusCode.NotFound;
var returnLink = Url.RouteUrl(RouteNames.VacancyManage_Get, new VacancyRouteModel
{
Ukprn = ukprn,
VacancyId = exception.VacancyId
});

return View(ViewNames.ApplicationWithdrawn, returnLink);
}

private void AddDashboardMessage(string message)
{
if(TempData.ContainsKey(TempDataKeys.VacanciesErrorMessage))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Esfa.Recruit.Vacancies.Client.Domain.Exceptions;

namespace Esfa.Recruit.Proivder.Web.Exceptions
{
public class ApplicationWithdrawnException : RecruitException
{
public Guid VacancyId { get;}

public ApplicationWithdrawnException(string message, Guid vacancyId) : base(message)
{
VacancyId = vacancyId;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Esfa.Recruit.Shared.Web.ViewModels.ApplicationReview;
using Esfa.Recruit.Proivder.Web.Exceptions;

namespace Esfa.Recruit.Provider.Web.Orchestrators
{
Expand All @@ -25,7 +26,7 @@ public async Task<ApplicationReviewViewModel> GetApplicationReviewViewModelAsync
var applicationReview = await Utility.GetAuthorisedApplicationReviewAsync(_vacancyClient, rm);

if (applicationReview.IsWithdrawn)
throw new Exception($"Application has been withdrawn. ApplicationReviewId:{applicationReview.Id}");
throw new ApplicationWithdrawnException($"Application has been withdrawn. ApplicationReviewId:{applicationReview.Id}", rm.VacancyId.Value);

return applicationReview.ToViewModel();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Provider/Provider.Web/Views/Error/ApplicationWithdrawn.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@model string

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl govuk-!-margin-bottom-0">This application has been withdrawn by the candidate</h1>

<p class="govuk-body govuk-!-margin-top-3">
<a href="@Model" class="govuk-button">Back to vacancy</a>
</p>
</div>
</div>

0 comments on commit cbc8f50

Please sign in to comment.