Skip to content

Commit 8bbb74d

Browse files
Merge pull request #40 from DFE-Digital/CL/facet-response-for-UI
Cl/facet response for UI
2 parents 081523a + 5c0e1c9 commit 8bbb74d

File tree

5 files changed

+87
-10
lines changed

5 files changed

+87
-10
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace Dfe.Data.SearchPrototype.SearchForEstablishments.Models;
2+
3+
/// <summary>
4+
/// The object that encapsulates the Faceted results returned by the
5+
/// T:Dfe.Data.SearchPrototype.SearchForEstablishments.SearchByKeywordUseCase instance
6+
/// </summary>
7+
public class EstablishmentFacet
8+
{
9+
/// <summary>
10+
/// The facet (field) name
11+
/// </summary>
12+
public string Name { get; }
13+
14+
/// <summary>
15+
/// The collection of T:Dfe.Data.SearchPrototype.SearchForEstablishments.Models.FacetResult
16+
/// </summary>
17+
public IList<FacetResult> Results { get; }
18+
19+
/// <summary>
20+
/// Constructor
21+
/// </summary>
22+
/// <param name="facetName"></param>
23+
/// <param name="facetResults"></param>
24+
public EstablishmentFacet(string facetName, IList<FacetResult> facetResults)
25+
{
26+
Name = facetName;
27+
Results = facetResults;
28+
}
29+
}

Dfe.Data.SearchPrototype/SearchForEstablishments/Models/EstablishmentStatusCode.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace Dfe.Data.SearchPrototype.SearchForEstablishments.Models;
2+
3+
/// <summary>
4+
/// The object that encapsulates a single facet result for a facet
5+
/// </summary>
6+
public class FacetResult
7+
{
8+
/// <summary>
9+
/// The value of the facet result
10+
/// </summary>
11+
public string Value { get; }
12+
13+
/// <summary>
14+
/// The number of records that belong to this facet value
15+
/// </summary>
16+
public int? Count { get; }
17+
18+
/// <summary>
19+
/// Constructor
20+
/// </summary>
21+
/// <param name="value">The value of the facet result</param>
22+
/// <param name="count">The number of records that belong to this facet value</param>
23+
public FacetResult(string value, int? count)
24+
{
25+
Value = value;
26+
Count = count;
27+
}
28+
}

Dfe.Data.SearchPrototype/SearchForEstablishments/SearchByKeywordResponse.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22

33
namespace Dfe.Data.SearchPrototype.SearchForEstablishments;
44

5+
6+
7+
58
/// <summary>
69
/// This is the object that carries the response (output) back from the
710
/// T:Dfe.Data.SearchPrototype.SearchForEstablishments.SearchByKeywordUseCase instance.
8-
/// The response will encapsulate any search results found along with a status.
911
/// </summary>
1012
public sealed class SearchByKeywordResponse
1113
{
1214
/// <summary>
1315
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.Establishment search results.
1416
/// </summary>
1517
public IReadOnlyCollection<Establishment> EstablishmentResults { get;}
18+
19+
/// <summary>
20+
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.EstablishmentFacet returned by the Establishment search
21+
/// </summary>
22+
public IReadOnlyCollection<EstablishmentFacet>? EstablishmentFacetResults { get; }
23+
24+
/// <summary>
25+
/// The return status of the call to the
26+
/// T:Dfe.Data.SearchPrototype.SearchForEstablishments.SearchByKeywordUseCase instance
27+
/// </summary>
1628
public SearchResponseStatus Status { get; set; }
1729

1830
/// <summary>
@@ -30,8 +42,12 @@ public SearchByKeywordResponse()
3042
/// <param name="establishments">
3143
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.Establishment search results.
3244
/// </param>
33-
public SearchByKeywordResponse(IReadOnlyCollection<Establishment> establishments)
45+
/// <param name="facetResults">
46+
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.EstablishmentFacet
47+
/// </param>
48+
public SearchByKeywordResponse(IReadOnlyCollection<Establishment> establishments, IReadOnlyCollection<EstablishmentFacet>? facetResults = null)
3449
{
3550
EstablishmentResults = establishments;
51+
EstablishmentFacetResults = facetResults;
3652
}
3753
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
namespace Dfe.Data.SearchPrototype.SearchForEstablishments;
22

3+
/// <summary>
4+
/// The status of the search response
5+
/// </summary>
36
public enum SearchResponseStatus
47
{
8+
/// <summary>
9+
/// The search request completed successfully
10+
/// </summary>
511
Success,
12+
/// <summary>
13+
/// The request was not valid
14+
/// </summary>
615
InvalidRequest,
16+
/// <summary>
17+
/// The request was submitted and resulted in an error
18+
/// </summary>
719
SearchServiceError
820
}

0 commit comments

Comments
 (0)