Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: split QualificationDetailsController.cs #479

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task<IActionResult> Confirm(ConfirmQualificationPageModel model)
"QualificationDetails",
new { qualificationId = model.QualificationId }),

_ => RedirectToAction("Get", "QualificationDetails")
_ => RedirectToAction("Get", "QualificationSearch")
};
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Dfe.EarlyYearsQualification.Web.Attributes;
using Dfe.EarlyYearsQualification.Web.Controllers.Base;
using Dfe.EarlyYearsQualification.Web.Services.QualificationSearch;
using Microsoft.AspNetCore.Mvc;

namespace Dfe.EarlyYearsQualification.Web.Controllers;

[Route("/qualifications")]
[RedirectIfDateMissing]
public class QualificationSearchController(
ILogger<QualificationSearchController> logger,
IQualificationSearchService qualificationSearchService)
: ServiceController
{
[HttpGet]
public async Task<IActionResult> Get()
{
var qualifications = await qualificationSearchService.GetQualifications();
if (qualifications is null)
{
logger.LogError("No content for the qualification list page");
return RedirectToAction("Index", "Error");
}

return View(qualifications);
}

[HttpPost]
public IActionResult Refine(string? refineSearch)
{
if (!ModelState.IsValid)
{
logger.LogWarning($"Invalid model state in {nameof(QualificationSearchController)} POST");
}

qualificationSearchService.Refine(refineSearch ?? string.Empty);

return RedirectToAction("Get");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public async Task<IActionResult> WhatIsTheAwardingOrganisation(DropdownQuestionM
userJourneyCookieService.SetAwardingOrganisation(model.NotInTheList ? string.Empty : model.SelectedValue!);
userJourneyCookieService.SetAwardingOrganisationNotOnList(model.NotInTheList);

return RedirectToAction("Get", "QualificationDetails");
return RedirectToAction("Get", "QualificationSearch");
}

private async Task<List<Qualification>> GetFilteredQualifications()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
using Dfe.EarlyYearsQualification.Content.Entities;

namespace Dfe.EarlyYearsQualification.Web.Models.Content;

public class BasicQualificationModel
{
protected BasicQualificationModel()
{
}

public BasicQualificationModel(Qualification qualification)
{
QualificationId = qualification.QualificationId;
QualificationLevel = qualification.QualificationLevel;
QualificationName = qualification.QualificationName;
AwardingOrganisationTitle = qualification.AwardingOrganisationTitle;
}

public string QualificationId { get; init; } = string.Empty;

public string QualificationName { get; init; } = string.Empty;

public string AwardingOrganisationTitle { get; init; } = string.Empty;

public int QualificationLevel { get; init; }
}
4 changes: 4 additions & 0 deletions src/Dfe.EarlyYearsQualification.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using Dfe.EarlyYearsQualification.Web.Services.Cookies;
using Dfe.EarlyYearsQualification.Web.Services.CookiesPreferenceService;
using Dfe.EarlyYearsQualification.Web.Services.DatesAndTimes;
using Dfe.EarlyYearsQualification.Web.Services.QualificationDetails;
using Dfe.EarlyYearsQualification.Web.Services.QualificationSearch;
using Dfe.EarlyYearsQualification.Web.Services.UserJourneyCookieService;
using GovUk.Frontend.AspNetCore;
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
Expand Down Expand Up @@ -99,6 +101,8 @@
builder.Services.AddTransient<IQualificationsRepository, QualificationsRepository>();
}

builder.Services.AddTransient<IQualificationDetailsService, QualificationDetailsService>();
builder.Services.AddTransient<IQualificationSearchService, QualificationSearchService>();
builder.Services.AddModelRenderers();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddScoped<ICookieManager, CookieManager>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Dfe.EarlyYearsQualification.Content.Entities;
using Dfe.EarlyYearsQualification.Web.Models.Content;

namespace Dfe.EarlyYearsQualification.Web.Services.QualificationDetails;

public interface IQualificationDetailsService
{
Task<Qualification?> GetQualification(string qualificationId);
Task<DetailsPage?> GetDetailsPage();
bool HasStartDate();
Task<string?> GetFeedbackBannerBodyToHtml(FeedbackBanner? feedbackBanner);
sam-c-dfe marked this conversation as resolved.
Show resolved Hide resolved
bool QualificationContainsQtsQuestion(Qualification qualification);
bool UserAnswerMatchesQtsQuestionAnswerToBeFullAndRelevant(Qualification qualification, List<AdditionalRequirementAnswerModel>? additionalRequirementAnswerModels);
bool AnswersIndicateNotFullAndRelevant(List<AdditionalRequirementAnswerModel> additionalRequirementsAnswers);
RatioRequirementModel MarkAsNotFullAndRelevant(RatioRequirementModel model);
Task QualificationLevel3OrAboveMightBeRelevantAtLevel2(QualificationDetailsModel model, Qualification qualification);
Task CheckRatioRequirements(Qualification qualification, QualificationDetailsModel model);
(bool isFullAndRelevant, QualificationDetailsModel details) RemainingAnswersIndicateFullAndRelevant(QualificationDetailsModel details, AdditionalRequirementQuestion qtsQuestion);
Task<QualificationDetailsModel> CheckLevel6Requirements(Qualification qualification, QualificationDetailsModel details);
bool DoAdditionalAnswersMatchQuestions(QualificationDetailsModel details);
NavigationLink? CalculateBackButton(DetailsPage content, string qualificationId);
List<AdditionalRequirementAnswerModel>? MapAdditionalRequirementAnswers(List<AdditionalRequirementQuestion>? additionalRequirementQuestions);
Task<QualificationDetailsModel> MapDetails(Qualification qualification, DetailsPage content);
}
Loading
Loading