-
Notifications
You must be signed in to change notification settings - Fork 3
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
Get Establishment by Trust Repository method #410
Changes from 6 commits
9a1b0cc
fc219a5
cefd20a
4dfabc5
de4f5ff
f96d781
75d8e05
9ed89e5
0318e73
95c1783
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.Academies.Domain.Establishment | ||
{ | ||
public class EducationEstablishmentTrust | ||
{ | ||
public int SK { get; set; } | ||
|
||
// Foreign keys | ||
public int FK_Trust { get; set; } | ||
public int FK_EducationEstablishment { get; set; } | ||
|
||
// Navigation properties | ||
public virtual Trust.Trust Trust { get; set; } | ||
public virtual Establishment Establishment { get; set; } | ||
Check warning on line 19 in Dfe.Academies.Domain/Establishment/EducationEstablishmentTrust.cs GitHub Actions / build-and-test
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,5 +168,33 @@ | |
var response = new List<EstablishmentDto>(establishments); | ||
return Ok(response); | ||
} | ||
/// <summary> | ||
/// Retrieves a list of establishments by their Trust UK Provider Reference Number (UKPRN) identifier. | ||
/// </summary> | ||
/// <param name="trustUkprn">Contains the Trust UK Provider Reference Number (UKPRN) identifier of the establishments.</param> | ||
/// /// <param name="cancellationToken"></param> | ||
/// <returns>List of establishments or NotFound if none are available.</returns> | ||
[HttpGet] | ||
[Route("establishments/trust")] | ||
[SwaggerOperation(Summary = "Get Establishments by Trust", Description = "Returns a list of establishments specified by Trust UKPRN.")] | ||
[SwaggerResponse(200, "Successfully found and returned the establishments.")] | ||
[SwaggerResponse(404, "Establishments with specified Trust UKPRN not found.")] | ||
public async Task<ActionResult<List<EstablishmentDto>>> GetByTrust([FromQuery] string trustUkprn, CancellationToken cancellationToken) | ||
{ | ||
var commaSeparatedRequestTrust = string.Join(",", trustUkprn); | ||
_logger.LogInformation($"Attemping to get establishments by Trust UKPRN : {commaSeparatedRequestTrust}"); | ||
|
||
var establishments = await _establishmentQueries.GetByTrust(trustUkprn, cancellationToken).ConfigureAwait(false); | ||
|
||
if (establishments == null) | ||
{ | ||
_logger.LogInformation($"No establishment was found with the requested Trust UKPRN : {commaSeparatedRequestTrust}"); | ||
Check notice Code scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarCloud
|
||
return NotFound(); | ||
} | ||
|
||
_logger.LogInformation($"Returning Establishments for Trust with specific UKPRN : {commaSeparatedRequestTrust}"); | ||
Check notice Code scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarCloud
|
||
var response = new List<EstablishmentDto>(establishments); | ||
return Ok(response); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,32 @@ | |
_logger.LogDebug(JsonSerializer.Serialize(trust)); | ||
return Ok(trust); | ||
} | ||
/// <summary> | ||
/// Retrieves a Trust by its Companies House Number. | ||
/// </summary> | ||
/// <param name="companiesHouseNumber">The Companies House Number identifier.</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns>A Trust or NotFound if not available.</returns> | ||
[HttpGet] | ||
[Route("trust/{ukprn}")] | ||
[SwaggerOperation(Summary = "Retrieve Trust by Companies House Number", Description = "Returns a Trust identified by Companies House Number.")] | ||
[SwaggerResponse(200, "Successfully found and returned the Trust.")] | ||
[SwaggerResponse(404, "Trust with specified Companies House Number not found.")] | ||
public async Task<ActionResult<TrustDto>> GetTrustByCompaniesHouseNumber(string companiesHouseNumber, CancellationToken cancellationToken) | ||
{ | ||
_logger.LogInformation($"Attempting to get trust by Companies House Number {companiesHouseNumber}"); | ||
Check notice Code scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarCloud
|
||
var trust = await _trustQueries.GetByCompaniesHouseNumber(companiesHouseNumber, cancellationToken).ConfigureAwait(false); | ||
|
||
if (trust == null) | ||
{ | ||
_logger.LogInformation($"No trust found for Companies House Number {companiesHouseNumber}"); | ||
Check notice Code scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarCloud
|
||
return NotFound(); | ||
} | ||
|
||
_logger.LogInformation($"Returning trust found by Companies House Number {companiesHouseNumber}"); | ||
Check notice Code scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarCloud
|
||
_logger.LogDebug(JsonSerializer.Serialize(trust)); | ||
return Ok(trust); | ||
} | ||
|
||
/// <summary> | ||
/// Searches for Trusts based on query parameters. | ||
|
Check notice
Code scanning / SonarCloud
Logging should not be vulnerable to injection attacks Low