Skip to content

Commit

Permalink
Updated search model to be used by both Conversions and Transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic NEED authored and Dominic NEED committed Apr 15, 2024
1 parent 3b33706 commit 2c4c844
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Dfe.Academies.Academisation.Data.ProjectAggregate
{
public class GetAcademyConversionSearchModel
public class GetProjectSearchModel
{
public GetAcademyConversionSearchModel(int page, int count, string? titleFilter,
public GetProjectSearchModel(int page, int count, string? titleFilter,
IEnumerable<string>? deliveryOfficerQueryString, IEnumerable<string>? regionQueryString,
IEnumerable<string>? statusQueryString, IEnumerable<string>? applicationReferences)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public async Task FormAMatApplicationExists___ApplicationIsSubmitted_And_Project

var projectController = new ProjectController(
Mock.Of<ICreateNewProjectCommand>(), new ConversionProjectQueryService(new ConversionProjectRepository(_context, null), new FormAMatProjectRepository(_context)), Mock.Of<IMediator>());
var projectResults = await projectController.GetProjects(new GetAcademyConversionSearchModel(1, 3, null, null, null, null, new[] { $"A2B_{createdPayload.ApplicationReference!}" }));
var projectResults = await projectController.GetProjects(new GetProjectSearchModel(1, 3, null, null, null, null, new[] { $"A2B_{createdPayload.ApplicationReference!}" }));

(_, PagedDataResponse<ConversionProjectServiceModel> projects) = DfeAssert.OkObjectResult(projectResults);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task ProjectsExists___ProjectListReturned()
await _context.Projects.AddAsync(project3);
await _context.SaveChangesAsync();

GetAcademyConversionSearchModel searchModel = new GetAcademyConversionSearchModel(1, 3, null, null, null, null, null);
GetProjectSearchModel searchModel = new GetProjectSearchModel(1, 3, null, null, null, null, null);
// act
var result = await _subject.GetProjects(searchModel);

Expand All @@ -61,7 +61,7 @@ public async Task ProjectsExists_ProjectListReturned_WithRegionFilter()
await _context.SaveChangesAsync();

string[] regions = { project1.Details.Region!.ToLower(), project2.Details.Region!.ToLower() };
GetAcademyConversionSearchModel searchModel = new GetAcademyConversionSearchModel(1, 3, null, null, regions, null, null);
GetProjectSearchModel searchModel = new GetProjectSearchModel(1, 3, null, null, regions, null, null);
// act
var result = await _subject.GetProjects(searchModel);

Expand All @@ -84,7 +84,7 @@ public async Task ProjectsExists_ProjectListReturned_WithApplicationIdFilter()
await _context.SaveChangesAsync();

string[] applicationReferences = { project1.Details.ApplicationReferenceNumber!, project2.Details.ApplicationReferenceNumber! };
GetAcademyConversionSearchModel searchModel = new GetAcademyConversionSearchModel(1, 3, null, null, null, null, applicationReferences);
GetProjectSearchModel searchModel = new GetProjectSearchModel(1, 3, null, null, null, null, applicationReferences);
// act
var result = await _subject.GetProjects(searchModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public async Task<ActionResult> SetIncomingTrust(int id, SetIncomingTrustCommand
/// <summary>
/// Retrieve all projects matching specified filter conditions
/// </summary>
/// <param name="searchModel"><see cref="GetAcademyConversionSearchModel"/> describing filtering requirements for the request</param>
/// <param name="searchModel"><see cref="GetProjectSearchModel"/> describing filtering requirements for the request</param>
/// <param name="urn">URN of a specific project to retrieve</param>
/// <remarks>
/// Filters are cumulative (AND logic), applied in the following order: by Region, by Status, by URN, by School, by
Expand All @@ -169,7 +169,7 @@ await _conversionProjectQueryService.GetProjectsV2(searchModel!.StatusQueryStrin
/// <summary>
/// Retrieve all form a mat projects matching specified filter conditions
/// </summary>
/// <param name="searchModel"><see cref="GetAcademyConversionSearchModel"/> describing filtering requirements for the request</param>
/// <param name="searchModel"><see cref="GetProjectSearchModel"/> describing filtering requirements for the request</param>
/// <param name="urn">URN of a specific project to retrieve</param>
/// <remarks>
/// Filters are cumulative (AND logic), applied in the following order: by Region, by Status, by URN, by School, by
Expand Down Expand Up @@ -303,22 +303,5 @@ public async Task<ActionResult> SetFormAMatProjectReference(
_ => throw new NotImplementedException()
};
}

[HttpDelete("{id:int}/Delete", Name = "DeleteProject")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> DeleteAProjectById(int id, CancellationToken cancellationToken)
{
SetDeletedAtCommand request = new SetDeletedAtCommand(id);

CommandResult result = await _mediator.Send(request);

return result switch
{
CommandSuccessResult => Ok(),
NotFoundCommandResult => NotFound(),
_ => throw new NotImplementedException()
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ProjectController(
/// <summary>
/// Retrieve all projects matching specified filter conditions
/// </summary>
/// <param name="searchModel"><see cref="GetAcademyConversionSearchModel"/> describing filtering requirements for the request</param>
/// <param name="searchModel"><see cref="GetProjectSearchModel"/> describing filtering requirements for the request</param>
/// <param name="urn">URN of a specific project to retrieve</param>
/// <remarks>
/// Filters are cumulative (AND logic), applied in the following order: by Region, by Status, by URN, by School, by
Expand All @@ -50,7 +50,7 @@ public ProjectController(
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<PagedDataResponse<ConversionProjectServiceModel>>> GetProjects(
GetAcademyConversionSearchModel? searchModel,
GetProjectSearchModel? searchModel,
[FromQuery] int? urn = null)
{
PagedDataResponse<ConversionProjectServiceModel>? result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public async Task<ActionResult<AcademyTransferProjectResponse>> GetTransferProje
/// </summary>
/// <param name="searchModel"><see cref="AcademyTransferProjectSummaryResponse"/> describing filtering requirements for the request</param>
/// <remarks>
/// Filters are cumulative (AND logic), applied in the following order: by Region, by Status, by URN, by School, by
/// Filters are cumulative (AND logic), applied in the following order: by Status, by URN, by
/// Delivery Officer.
/// </remarks>
/// <response code="200">One or more projects matching the specified filter criteria were found</response>
Expand All @@ -290,7 +290,7 @@ public async Task<ActionResult<AcademyTransferProjectResponse>> GetTransferProje
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<PagedDataResponse<AcademyTransferProjectSummaryResponse>>> GetProjects(
GetAcademyConversionSearchModel? searchModel)
GetProjectSearchModel? searchModel)
{
PagedDataResponse<AcademyTransferProjectSummaryResponse>? result =
await _transferProjectQueryService.GetProjects(searchModel!.StatusQueryString, searchModel.TitleFilter,
Expand Down

0 comments on commit 2c4c844

Please sign in to comment.