-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from DFE-Digital/support-project-base-page
support project base
- Loading branch information
Showing
3 changed files
with
63 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/Dfe.RegionalImprovementForStandardsAndExcellence/Pages/BaseSupportProjectPageModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters