Skip to content

changed endpoint for getting al hightlights. Status code is now 200 w… #248

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

Merged
merged 12 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions API/Controllers/EmbedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Linq.Expressions;
using System.Threading.Tasks;

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

if(!embeddedProjects.Any())
{
ProblemDetails problem = new ProblemDetails
{
Title = "No Embedded Projects found.",
Detail = "There are no Embedded projects in the database.",
Instance = "FEA62EAE-3D3C-4CE7-BDD8-6B273D56068D"
};
return NotFound(problem);
}
return Ok(mapper.Map<IEnumerable<EmbeddedProject>, IEnumerable<EmbeddedProjectResourceResult>>(embeddedProjects));
}

Expand Down
14 changes: 2 additions & 12 deletions API/Controllers/HighlightController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Models.Defaults;
using Serilog;
using Services.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -58,23 +59,12 @@ public HighlightController(IHighlightService highlightService, IMapper mapper)
/// </summary>
/// <returns>This method returns a list of highlight resource results.</returns>
/// <response code="200">This endpoint returns a list highlights.</response>
/// <response code="404">The 404 Not Found status code is returned when there are no highlights found.</response>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<HighlightResourceResult>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
public async Task<IActionResult> GetAllHighlights()
{
IEnumerable<Highlight> highlights = await highlightService.GetHighlightsAsync();
if(!highlights.Any())
{
ProblemDetails problem = new ProblemDetails
{
Title = "Failed getting highlights.",
Detail = "The database does not contain any highlights.",
Instance = "FC6A4F97-C815-4A92-8A73-2ECF1729B161"
};
return NotFound(problem);
}

return Ok(mapper.Map<IEnumerable<Highlight>, IEnumerable<HighlightResourceResult>>(highlights));
}

Expand Down
17 changes: 4 additions & 13 deletions API/Controllers/RoleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Models.Defaults;
using Serilog;
using Services.Services;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
Expand Down Expand Up @@ -44,24 +45,13 @@ public RoleController(IRoleService roleService, IUserService userService, IMappe
/// </summary>
/// <returns>This method returns a list of role resource results.</returns>
/// <response code="200">This endpoint returns a list of roles.</response>
/// <response code="404">The 404 Not Found status code is returned when no roles are found.</response>
[HttpGet]
[Authorize(Policy = nameof(Scopes.RoleRead))]
[ProducesResponseType(typeof(IEnumerable<RoleResourceResult>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(ProblemDetails), (int) HttpStatusCode.NotFound)]
public async Task<IActionResult> GetAllRoles()
{
List<Role> roles = await roleService.GetAllAsync().ConfigureAwait(false);
if(roles.Count == 0)
{
ProblemDetails problem = new ProblemDetails
{
Title = "Failed getting all roles.",
Detail = "There where no roles found in the database.",
Instance = "3EB1E953-96D7-45FE-8C5C-05306AF8D060"
};
return NotFound(problem);
}
List<Role> roles = await roleService.GetAllAsync()
.ConfigureAwait(false);

return Ok(mapper.Map<IEnumerable<Role>, IEnumerable<RoleResourceResult>>(roles));
}
Expand Down Expand Up @@ -89,6 +79,7 @@ public IActionResult GetAllPossibleScopes()
};
return NotFound(problem);
}

return Ok(scopeList);
}

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

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

### Security
Expand Down