Skip to content

Commit f34215b

Browse files
Merge pull request #413 from DFE-Digital/feature/trust-v4-endpoint
Feature/trust v4 endpoint
2 parents ef35dd1 + 909523e commit f34215b

File tree

17 files changed

+54
-38
lines changed

17 files changed

+54
-38
lines changed

Dfe.Academies.Api.Infrastructure/Dfe.Academies.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.2" />
10+
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
1111
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.24" />
1212
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.24">
1313
<PrivateAssets>all</PrivateAssets>

Dfe.Academies.Api.Infrastructure/Repositories/TrustRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public async Task<List<Trust>> GetTrustsByUkprns(string[] ukprns, CancellationTo
3535
return trusts;
3636
}
3737

38-
public async Task<List<Trust>> Search(int page, int count, string name, string ukPrn, string companiesHouseNumber, CancellationToken cancellationToken)
38+
public async Task<(List<Trust>, int)> Search(int page, int count, string name, string ukPrn, string companiesHouseNumber, CancellationToken cancellationToken)
3939
{
4040
if (name == null && ukPrn == null && companiesHouseNumber == null)
4141
{
4242
List<Trust> allTrusts = await dbSet.OrderBy(trust => trust.GroupUID).Skip((page - 1) * count)
4343
.Take(count).ToListAsync(cancellationToken).ConfigureAwait(false);
44-
return allTrusts;
44+
return (allTrusts, allTrusts.Count);
4545
}
4646

4747
IOrderedQueryable<Trust> filteredGroups = dbSet
@@ -54,7 +54,7 @@ public async Task<List<Trust>> Search(int page, int count, string name, string u
5454
))
5555
.OrderBy(trust => trust.GroupUID);
5656

57-
return await filteredGroups.Skip((page - 1) * count).Take(count).ToListAsync(cancellationToken).ConfigureAwait(false);
57+
return (await filteredGroups.Skip((page - 1) * count).Take(count).ToListAsync(cancellationToken).ConfigureAwait(false), filteredGroups.Count());
5858
}
5959
}
6060
}

Dfe.Academies.Application.Tests/Queries/Establishment/EstablishmentQueriesTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using AutoFixture;
22
using Dfe.Academies.Application.Queries.Establishment;
3-
using Dfe.Academies.Contracts.Establishments;
4-
using Dfe.Academies.Contracts.Trusts;
3+
using Dfe.Academies.Contracts.V4.Establishments;
54
using Dfe.Academies.Domain.Establishment;
65
using Dfe.Academies.Domain.Trust;
76
using FluentAssertions;
87
using Moq;
9-
using System.Runtime.CompilerServices;
108

119
namespace Dfe.Academies.Application.Tests.Queries.Establishment
1210
{

Dfe.Academies.Application.Tests/Queries/Trust/TrustQueriesTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using AutoFixture;
22
using Dfe.Academies.Application.Queries.Trust;
3-
using Dfe.Academies.Contracts.Trusts;
3+
using Dfe.Academies.Contracts.V4.Trusts;
44
using Dfe.Academies.Domain.Trust;
55
using FluentAssertions;
66
using Moq;
@@ -57,7 +57,7 @@ public async Task Search_TrustsReturnedFromRepo_eturnsAListOfTrustDtosInAPagedRe
5757
// Arrange
5858
var trusts = _fixture.Create<List<Domain.Trust.Trust>>();
5959
var mockRepo = new Mock<ITrustRepository>();
60-
mockRepo.Setup(x => x.Search(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(trusts));
60+
mockRepo.Setup(x => x.Search(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult((trusts, trusts.Count)));
6161

6262
var trustQueries = new TrustQueries(mockRepo.Object);
6363
int page = 0;

Dfe.Academies.Application/Builders/EstablishmentDtoBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Dfe.Academies.Contracts.Establishments;
1+
using Dfe.Academies.Contracts.V4;
2+
using Dfe.Academies.Contracts.V4.Establishments;
23

34
namespace Dfe.Academies.Application.Builders
45
{
@@ -128,7 +129,7 @@ public EstablishmentDtoBuilder WithMISEstablishment(Domain.Establishment.Establi
128129

129130
public EstablishmentDtoBuilder WithAddress(Domain.Establishment.Establishment establishment)
130131
{
131-
_dto.Address = new Contracts.Trusts.AddressDto()
132+
_dto.Address = new AddressDto()
132133
{
133134
Street = establishment?.AddressLine1,
134135
Town = establishment?.Town,

Dfe.Academies.Application/Dfe.Academies.Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.2" />
10+
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
1111
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
1212
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
1313
</ItemGroup>

Dfe.Academies.Application/Queries/Establishment/EstablishmentQueries.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using Dfe.Academies.Contracts.Establishments;
2-
using Dfe.Academies.Contracts.Trusts;
1+
using Dfe.Academies.Contracts.V4.Establishments;
32
using Dfe.Academies.Domain.Establishment;
4-
using System.Threading;
5-
using System;
3+
64
using Dfe.Academies.Application.Builders;
75
using Dfe.Academies.Domain.Trust;
86

Dfe.Academies.Application/Queries/Establishment/IEstablishmentQueries.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using Dfe.Academies.Contracts.Establishments;
2-
using Dfe.Academies.Contracts.Trusts;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
1+
using Dfe.Academies.Contracts.V4.Establishments;
82

93
namespace Dfe.Academies.Application.Queries.Establishment
104
{

Dfe.Academies.Application/Queries/Trust/ITrustQueries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Dfe.Academies.Contracts.Trusts;
1+
using Dfe.Academies.Contracts.V4.Trusts;
22

33
namespace Dfe.Academies.Application.Queries.Trust
44
{

Dfe.Academies.Application/Queries/Trust/TrustQueries.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Dfe.Academies.Contracts.Trusts;
1+
using Dfe.Academies.Contracts.V4;
2+
using Dfe.Academies.Contracts.V4.Trusts;
23
using Dfe.Academies.Domain.Trust;
34

45
namespace Dfe.Academies.Application.Queries.Trust
@@ -24,9 +25,9 @@ public TrustQueries(ITrustRepository trustRepository)
2425

2526
public async Task<(List<TrustDto>, int)> Search(int page, int count, string name, string ukPrn, string companiesHouseNumber, CancellationToken cancellationToken)
2627
{
27-
var trusts = await _trustRepository.Search(page, count, name, ukPrn, companiesHouseNumber, cancellationToken).ConfigureAwait(false);
28+
var (trusts, recordCount) = await _trustRepository.Search(page, count, name, ukPrn, companiesHouseNumber, cancellationToken).ConfigureAwait(false);
2829

29-
return (trusts.Select(x => MapToTrustDto(x)).ToList(), trusts.Count);
30+
return (trusts.Select(x => MapToTrustDto(x)).ToList(), recordCount);
3031
}
3132

3233
public async Task<List<TrustDto>> GetByUkprns(string[] ukprns, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)