-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from davewalker5/DFL-25-Add-Maintenance-Log
Dfl 25 add maintenance log
- Loading branch information
Showing
106 changed files
with
5,285 additions
and
1,924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:latest | ||
COPY droneflightlog.api-1.2.1.0 /opt/droneflightlog.api-1.2.1.0 | ||
WORKDIR /opt/droneflightlog.api-1.2.1.0/bin | ||
COPY droneflightlog.api-1.3.0.0 /opt/droneflightlog.api-1.3.0.0 | ||
WORKDIR /opt/droneflightlog.api-1.3.0.0/bin | ||
ENTRYPOINT [ "./DroneFlightLog.Api" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:latest | ||
COPY droneflightlog.mvc-1.1.4.0 /opt/droneflightlog.mvc-1.1.4.0 | ||
WORKDIR /opt/droneflightlog.mvc-1.1.4.0/bin | ||
COPY droneflightlog.mvc-1.2.0.0 /opt/droneflightlog.mvc-1.2.0.0 | ||
WORKDIR /opt/droneflightlog.mvc-1.2.0.0/bin | ||
ENTRYPOINT [ "./DroneFlightLog.Mvc" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
src/DroneFlightLog.Api/Controllers/MaintainersController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using DroneFlightLog.Data.Entities; | ||
using DroneFlightLog.Data.Exceptions; | ||
using DroneFlightLog.Data.Interfaces; | ||
using DroneFlightLog.Data.Sqlite; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Web; | ||
|
||
namespace DroneFlightLog.Api.Controllers | ||
{ | ||
[Authorize] | ||
[ApiController] | ||
[ApiConventionType(typeof(DefaultApiConventions))] | ||
[Route("[controller]")] | ||
public class MaintainersController : Controller | ||
{ | ||
private readonly IDroneFlightLogFactory<DroneFlightLogDbContext> _factory; | ||
|
||
public MaintainersController(IDroneFlightLogFactory<DroneFlightLogDbContext> factory) | ||
{ | ||
_factory = factory; | ||
} | ||
|
||
[HttpGet] | ||
[Route("{id}")] | ||
public async Task<ActionResult<Maintainer>> GetMaintainerAsync(int id) | ||
{ | ||
Maintainer maintainer; | ||
|
||
try | ||
{ | ||
maintainer = await _factory.Maintainers.GetMaintainerAsync(id); | ||
} | ||
catch (MaintainerNotFoundException) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return maintainer; | ||
} | ||
|
||
[HttpGet] | ||
[Route("")] | ||
public async Task<ActionResult<List<Maintainer>>> GetMaintainersAsync() | ||
{ | ||
List<Maintainer> maintainers = await _factory.Maintainers.GetMaintainersAsync().ToListAsync(); | ||
|
||
if (maintainers.Count == 0) | ||
{ | ||
return NoContent(); | ||
} | ||
|
||
return maintainers; | ||
} | ||
|
||
[HttpGet] | ||
[Route("{firstNames}/{surname}")] | ||
public async Task<ActionResult<Maintainer>> FindMaintainerAsync(string firstNames, string surname) | ||
{ | ||
string decodedFirstNames = HttpUtility.UrlDecode(firstNames); | ||
string decodedSurname = HttpUtility.UrlDecode(surname); | ||
Maintainer maintainer = await _factory.Maintainers.FindMaintainerAsync(decodedFirstNames, decodedSurname); | ||
|
||
if (maintainer == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return maintainer; | ||
} | ||
|
||
[HttpPut] | ||
[Route("")] | ||
public async Task<ActionResult<Maintainer>> UpdateMaintainerAsync([FromBody] Maintainer template) | ||
{ | ||
Maintainer maintainer; | ||
|
||
try | ||
{ | ||
maintainer = await _factory.Maintainers.UpdateMaintainerAsync(template.Id, | ||
template.FirstNames, | ||
template.Surname); | ||
await _factory.Context.SaveChangesAsync(); | ||
} | ||
catch (MaintainerNotFoundException) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return maintainer; | ||
} | ||
|
||
[HttpPost] | ||
[Route("")] | ||
public async Task<ActionResult<Maintainer>> CreateMaintainerAsync([FromBody] Maintainer template) | ||
{ | ||
Maintainer maintainer; | ||
|
||
try | ||
{ | ||
maintainer = await _factory.Maintainers.AddMaintainerAsync(template.FirstNames, | ||
template.Surname); | ||
await _factory.Context.SaveChangesAsync(); | ||
} | ||
catch (MaintainerExistsException) | ||
{ | ||
return BadRequest(); | ||
} | ||
|
||
return maintainer; | ||
} | ||
} | ||
} |
Oops, something went wrong.