-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rovecomm merge to implement into Raman-graph
- Loading branch information
Showing
45 changed files
with
5,605 additions
and
1,269 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
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
172 changes: 85 additions & 87 deletions
172
Basestation_Software.Api/Controllers/GPSWaypointController.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 |
---|---|---|
@@ -1,111 +1,109 @@ | ||
using Basestation_Software.Api.Entities; | ||
using Basestation_Software.Models.Geospatial; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Basestation_Software.Api.Controllers | ||
namespace Basestation_Software.Api.Controllers; | ||
|
||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class GPSWaypointController : ControllerBase | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class GPSWaypointController : ControllerBase | ||
// Declare member variables. | ||
private readonly IGPSWaypointRepository _GPSWaypointRepository; | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
/// <param name="GPSWaypointRepository">Implicitly passed in.</param> | ||
public GPSWaypointController(IGPSWaypointRepository GPSWaypointRepository) | ||
{ | ||
// Declare member variables. | ||
private readonly IGPSWaypointRepository _GPSWaypointRepository; | ||
_GPSWaypointRepository = GPSWaypointRepository; | ||
} | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
/// <param name="GPSWaypointRepository">Implicitly passed in.</param> | ||
public GPSWaypointController(IGPSWaypointRepository GPSWaypointRepository) | ||
/// <summary> | ||
/// IN-Code API Endpoint for adding a waypoint to the DB. | ||
/// </summary> | ||
/// <param name="waypoint">The waypoint object.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpPut] | ||
public async Task<IActionResult> AddGPSWaypoint(GPSWaypoint waypoint) | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.AddGPSWaypoint(waypoint); | ||
if (dbWaypoint is not null) | ||
{ | ||
_GPSWaypointRepository = GPSWaypointRepository; | ||
return Ok(); | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for adding a waypoint to the DB. | ||
/// </summary> | ||
/// <param name="waypoint">The waypoint object.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpPut] | ||
public async Task<IActionResult> AddGPSWaypoint(GPSWaypoint waypoint) | ||
else | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.AddGPSWaypoint(waypoint); | ||
if (dbWaypoint is not null) | ||
{ | ||
return Ok(); | ||
} | ||
else | ||
{ | ||
return BadRequest(); | ||
} | ||
return BadRequest(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for removing a waypoint from the DB. | ||
/// </summary> | ||
/// <param name="waypointID">The waypoint ID.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpDelete("{waypointID}")] | ||
public async Task<IActionResult> DeleteGPSWaypoint(int waypointID) | ||
/// <summary> | ||
/// IN-Code API Endpoint for removing a waypoint from the DB. | ||
/// </summary> | ||
/// <param name="waypointID">The waypoint ID.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpDelete("{waypointID}")] | ||
public async Task<IActionResult> DeleteGPSWaypoint(int waypointID) | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.DeleteGPSWaypoint(waypointID); | ||
if (dbWaypoint is not null) | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.DeleteGPSWaypoint(waypointID); | ||
if (dbWaypoint is not null) | ||
{ | ||
return Ok(); | ||
} | ||
else | ||
{ | ||
return NotFound(); | ||
} | ||
return Ok(); | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for getting a waypoint to the DB. | ||
/// </summary> | ||
/// <param name="waypointID">The waypoint id.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpGet("{waypointID}")] | ||
public async Task<IActionResult> GetGPSWaypoint(int waypointID) | ||
else | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.GetGPSWaypoint(waypointID); | ||
if (dbWaypoint is not null) | ||
{ | ||
return Ok(dbWaypoint); | ||
} | ||
else | ||
{ | ||
return NotFound(); | ||
} | ||
return NotFound(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for getting all waypoints from the DB. | ||
/// </summary> | ||
/// <returns>The API response object.</returns> | ||
[HttpGet] | ||
public async Task<IActionResult> GetAllGPSWaypoints() | ||
/// <summary> | ||
/// IN-Code API Endpoint for getting a waypoint to the DB. | ||
/// </summary> | ||
/// <param name="waypointID">The waypoint id.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpGet("{waypointID}")] | ||
public async Task<IActionResult> GetGPSWaypoint(int waypointID) | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.GetGPSWaypoint(waypointID); | ||
if (dbWaypoint is not null) | ||
{ | ||
return Ok(await _GPSWaypointRepository.GetAllGPSWaypoints()); | ||
return Ok(dbWaypoint); | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for updating a waypoint to the DB. | ||
/// </summary> | ||
/// <param name="waypoint">The waypoint object.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpPost] | ||
public async Task<IActionResult> UpdateGPSWaypoint(GPSWaypoint waypoint) | ||
else | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.UpdateGPSWaypoint(waypoint); | ||
if (dbWaypoint is not null) | ||
{ | ||
return Ok(dbWaypoint); | ||
} | ||
else | ||
{ | ||
return NotFound(); | ||
} | ||
return NotFound(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for getting all waypoints from the DB. | ||
/// </summary> | ||
/// <returns>The API response object.</returns> | ||
[HttpGet] | ||
public async Task<IActionResult> GetAllGPSWaypoints() | ||
{ | ||
return Ok(await _GPSWaypointRepository.GetAllGPSWaypoints()); | ||
} | ||
|
||
/// <summary> | ||
/// IN-Code API Endpoint for updating a waypoint to the DB. | ||
/// </summary> | ||
/// <param name="waypoint">The waypoint object.</param> | ||
/// <returns>The API response object.</returns> | ||
[HttpPost] | ||
public async Task<IActionResult> UpdateGPSWaypoint(GPSWaypoint waypoint) | ||
{ | ||
GPSWaypoint? dbWaypoint = await _GPSWaypointRepository.UpdateGPSWaypoint(waypoint); | ||
if (dbWaypoint is not null) | ||
{ | ||
return Ok(dbWaypoint); | ||
} | ||
else | ||
{ | ||
return NotFound(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.