Skip to content

Commit 27258d7

Browse files
authored
Merge pull request #248 from DigitalExcellence/bugfix/207-highlight-status-code
2 parents b0f1ac9 + 4526341 commit 27258d7

File tree

4 files changed

+9
-38
lines changed

4 files changed

+9
-38
lines changed

API/Controllers/EmbedController.cs

+2-13
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using System.Collections.Generic;
3030
using System.Linq;
3131
using System.Net;
32+
using System.Linq.Expressions;
3233
using System.Threading.Tasks;
3334

3435
namespace API.Controllers
@@ -67,25 +68,13 @@ public EmbedController(IEmbedService embedService, IMapper mapper, IProjectServi
6768
/// </summary>
6869
/// <returns>This method returns a list of embedded projects resource result.</returns>
6970
/// <response code="200">This endpoint returns a list with embedded projects.</response>
70-
/// <response code="404">The 404 Not Found status code is returned when there are no embedded projects.</response>
7171
[HttpGet]
7272
[ProducesResponseType(typeof(IEnumerable<EmbeddedProjectResourceResult>), (int) HttpStatusCode.OK)]
73-
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
7473
[Authorize(Policy = nameof(Defaults.Scopes.EmbedRead))]
7574
public async Task<IActionResult> GetAllEmbeddedProjects()
7675
{
77-
IEnumerable<EmbeddedProject> embeddedProjects = await embedService.GetEmbeddedProjectsAsync();
76+
IEnumerable<EmbeddedProject> embeddedProjects= await embedService.GetEmbeddedProjectsAsync();
7877

79-
if(!embeddedProjects.Any())
80-
{
81-
ProblemDetails problem = new ProblemDetails
82-
{
83-
Title = "No Embedded Projects found.",
84-
Detail = "There are no Embedded projects in the database.",
85-
Instance = "FEA62EAE-3D3C-4CE7-BDD8-6B273D56068D"
86-
};
87-
return NotFound(problem);
88-
}
8978
return Ok(mapper.Map<IEnumerable<EmbeddedProject>, IEnumerable<EmbeddedProjectResourceResult>>(embeddedProjects));
9079
}
9180

API/Controllers/HighlightController.cs

+2-12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Models.Defaults;
2525
using Serilog;
2626
using Services.Services;
27+
using System;
2728
using System.Collections.Generic;
2829
using System.Linq;
2930
using System.Net;
@@ -58,23 +59,12 @@ public HighlightController(IHighlightService highlightService, IMapper mapper)
5859
/// </summary>
5960
/// <returns>This method returns a list of highlight resource results.</returns>
6061
/// <response code="200">This endpoint returns a list highlights.</response>
61-
/// <response code="404">The 404 Not Found status code is returned when there are no highlights found.</response>
6262
[HttpGet]
6363
[ProducesResponseType(typeof(IEnumerable<HighlightResourceResult>), (int) HttpStatusCode.OK)]
64-
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
6564
public async Task<IActionResult> GetAllHighlights()
6665
{
6766
IEnumerable<Highlight> highlights = await highlightService.GetHighlightsAsync();
68-
if(!highlights.Any())
69-
{
70-
ProblemDetails problem = new ProblemDetails
71-
{
72-
Title = "Failed getting highlights.",
73-
Detail = "The database does not contain any highlights.",
74-
Instance = "FC6A4F97-C815-4A92-8A73-2ECF1729B161"
75-
};
76-
return NotFound(problem);
77-
}
67+
7868
return Ok(mapper.Map<IEnumerable<Highlight>, IEnumerable<HighlightResourceResult>>(highlights));
7969
}
8070

API/Controllers/RoleController.cs

+4-13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Models.Defaults;
88
using Serilog;
99
using Services.Services;
10+
using System;
1011
using System.Collections.Generic;
1112
using System.Net;
1213
using System.Threading.Tasks;
@@ -44,24 +45,13 @@ public RoleController(IRoleService roleService, IUserService userService, IMappe
4445
/// </summary>
4546
/// <returns>This method returns a list of role resource results.</returns>
4647
/// <response code="200">This endpoint returns a list of roles.</response>
47-
/// <response code="404">The 404 Not Found status code is returned when no roles are found.</response>
4848
[HttpGet]
4949
[Authorize(Policy = nameof(Scopes.RoleRead))]
5050
[ProducesResponseType(typeof(IEnumerable<RoleResourceResult>), (int) HttpStatusCode.OK)]
51-
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
5251
public async Task<IActionResult> GetAllRoles()
5352
{
54-
List<Role> roles = await roleService.GetAllAsync().ConfigureAwait(false);
55-
if(roles.Count == 0)
56-
{
57-
ProblemDetails problem = new ProblemDetails
58-
{
59-
Title = "Failed getting all roles.",
60-
Detail = "There where no roles found in the database.",
61-
Instance = "3EB1E953-96D7-45FE-8C5C-05306AF8D060"
62-
};
63-
return NotFound(problem);
64-
}
53+
List<Role> roles = await roleService.GetAllAsync()
54+
.ConfigureAwait(false);
6555

6656
return Ok(mapper.Map<IEnumerable<Role>, IEnumerable<RoleResourceResult>>(roles));
6757
}
@@ -89,6 +79,7 @@ public IActionResult GetAllPossibleScopes()
8979
};
9080
return NotFound(problem);
9181
}
82+
9283
return Ok(scopeList);
9384
}
9485

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525

2626
### Fixed
2727

28+
- Fixed a bug where GetAllHighlights endpoint return status code 404 when empty. - [#207](https://github.com/DigitalExcellence/dex-backend/issues/207)
2829
- Fixed issue where local docker-compose would not work due to missing connection string - [#234](https://github.com/DigitalExcellence/dex-backend/issues/234)
2930

3031
### Security

0 commit comments

Comments
 (0)