Skip to content

Commit

Permalink
Merge pull request #18 from DFE-Digital/support-project-base-page
Browse files Browse the repository at this point in the history
support project base
  • Loading branch information
paullocknimble authored Jan 2, 2025
2 parents 9a9dcdc + aed56a7 commit 0c627d8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,28 @@

namespace Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Pages.AboutTheSchool;

public class IndexModel(
ISupportProjectQueryService _supportProjectQueryService,
ErrorService errorService,IGetEstablishment _getEstablishment
) : PageModel
public class IndexModel : BaseSupportProjectPageModel
{
//protected readonly ISession _session = session;
public SupportProjectViewModel SupportProject { get; set; }
public string ReturnPage { get; set; }

public void SetErrorPage(string errorPage)
{
TempData["ErrorPage"] = errorPage;
}

public IndexModel(ISupportProjectQueryService supportProjectQueryService, IGetEstablishment getEstablishment) : base(supportProjectQueryService,getEstablishment)
{

}

public async Task<IActionResult> OnGetAsync(int id, CancellationToken cancellationToken)
{
ProjectListFilters.ClearFiltersFrom(TempData);

var result = await _supportProjectQueryService.GetSupportProject(id, cancellationToken);

if (result.IsSuccess && result.Value != null)
{
SupportProject = SupportProjectViewModel.Create(result.Value);

DfE.CoreLibs.Contracts.Academies.V4.Establishments.EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(result.Value.schoolUrn);

SupportProject.QualityOfEducation = establishment.MISEstablishment.QualityOfEducation;
SupportProject.LastInspectionDate = establishment.OfstedLastInspection;
SupportProject.BehaviourAndAttitudes = establishment.MISEstablishment.BehaviourAndAttitudes;
SupportProject.PersonalDevelopment = establishment.MISEstablishment.PersonalDevelopment;
SupportProject.LeadershipAndManagement = establishment.MISEstablishment.EffectivenessOfLeadershipAndManagement;
}



ReturnPage = @Links.ProjectList.Index.Page;

if (!result.IsSuccess)
{
return NotFound();
}

await base.GetSupportProject(id, cancellationToken);

return Page();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Dfe.RegionalImprovementForStandardsAndExcellence.Application.SupportProject.Queries;
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Interfaces.Repositories;
using Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Models.SupportProject;
using Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Pages;

public class BaseSupportProjectPageModel(ISupportProjectQueryService supportProjectQueryService,IGetEstablishment getEstablishment) : PageModel
{
protected readonly ISupportProjectQueryService _supportProjectQueryService = supportProjectQueryService;
protected readonly IGetEstablishment _getEstablishment = getEstablishment;

public SupportProjectViewModel SupportProject { get; set; }

public virtual async Task<IActionResult> GetSupportProject(int id, CancellationToken cancellationToken)
{
return await GetProject(id,cancellationToken);
}
protected async Task<IActionResult> GetProject(int id, CancellationToken cancellationToken)
{

var result = await _supportProjectQueryService.GetSupportProject(id, cancellationToken);

if (result.IsSuccess && result.Value != null)
{
SupportProject = SupportProjectViewModel.Create(result.Value);

DfE.CoreLibs.Contracts.Academies.V4.Establishments.EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(result.Value.schoolUrn);

SupportProject.QualityOfEducation = establishment.MISEstablishment.QualityOfEducation;
SupportProject.LastInspectionDate = establishment.OfstedLastInspection;
SupportProject.BehaviourAndAttitudes = establishment.MISEstablishment.BehaviourAndAttitudes;
SupportProject.PersonalDevelopment = establishment.MISEstablishment.PersonalDevelopment;
SupportProject.LeadershipAndManagement = establishment.MISEstablishment.EffectivenessOfLeadershipAndManagement;
}

if (!result.IsSuccess)
{
return NotFound();
}
return Page();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,27 @@

namespace Dfe.RegionalImprovementForStandardsAndExcellence.Frontend.Pages.TaskList;

public class IndexModel(
ISupportProjectQueryService _supportProjectQueryService,
ErrorService errorService,IGetEstablishment _getEstablishment
) : PageModel
public class IndexModel : BaseSupportProjectPageModel
{
//protected readonly ISession _session = session;
public SupportProjectViewModel SupportProject { get; set; }
public string ReturnPage { get; set; }

public void SetErrorPage(string errorPage)
{
TempData["ErrorPage"] = errorPage;
}

public IndexModel(ISupportProjectQueryService supportProjectQueryService, IGetEstablishment getEstablishment) : base(supportProjectQueryService,getEstablishment)
{

}

public async Task<IActionResult> OnGetAsync(int id, CancellationToken cancellationToken)
{
ProjectListFilters.ClearFiltersFrom(TempData);

var result = await _supportProjectQueryService.GetSupportProject(id, cancellationToken);

if (result.IsSuccess && result.Value != null)
{
SupportProject = SupportProjectViewModel.Create(result.Value);

DfE.CoreLibs.Contracts.Academies.V4.Establishments.EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(result.Value.schoolUrn);

SupportProject.QualityOfEducation = establishment.MISEstablishment.QualityOfEducation;
SupportProject.LastInspectionDate = establishment.OfstedLastInspection;
SupportProject.BehaviourAndAttitudes = establishment.MISEstablishment.BehaviourAndAttitudes;
SupportProject.PersonalDevelopment = establishment.MISEstablishment.PersonalDevelopment;
SupportProject.LeadershipAndManagement = establishment.MISEstablishment.EffectivenessOfLeadershipAndManagement;
}



ReturnPage = @Links.ProjectList.Index.Page;

if (!result.IsSuccess)
{
return NotFound();
}

await base.GetSupportProject(id, cancellationToken);

return Page();
}
Expand Down

0 comments on commit 0c627d8

Please sign in to comment.