Update survey response, adding EmployeeId , Location Id as int, adjust end point for ansers submission in batch

This commit is contained in:
Reginald Cherenfant Jasmin
2023-09-13 01:28:24 -04:00
parent 4cf7d9f891
commit 9109d0d793
68 changed files with 525 additions and 540 deletions

View File

@ -4,12 +4,10 @@ using Microsoft.AspNetCore.Mvc;
namespace DamageAssesment.Api.Locations.Controllers
{
[Route("api")]
[ApiController]
public class LocationsController : ControllerBase
{
private ILocationsProvider LocationProvider;
public LocationsController(ILocationsProvider LocationsProvider)
{
this.LocationProvider = LocationsProvider;
@ -25,7 +23,7 @@ namespace DamageAssesment.Api.Locations.Controllers
var result = await LocationProvider.GetLocationsAsync();
if (result.IsSuccess)
{
return Ok(result.locations);
return Ok(result.Locations);
}
return NoContent();
@ -35,7 +33,7 @@ namespace DamageAssesment.Api.Locations.Controllers
/// </summary>
[HttpGet("Locations/{id}")]
public async Task<ActionResult> GetLocationByIdAsync(string id)
public async Task<ActionResult> GetLocationByIdAsync(int id)
{
var result = await LocationProvider.GetLocationByIdAsync(id);
@ -50,15 +48,15 @@ namespace DamageAssesment.Api.Locations.Controllers
/// Update a Location.
/// </summary>
[HttpPut("Locations")]
public async Task<IActionResult> UpdateLocation(Models.Location Location)
[HttpPut("Locations/{id}")]
public async Task<IActionResult> UpdateLocation(int id, Models.Location Location)
{
if (Location != null)
{
var result = await this.LocationProvider.UpdateLocationAsync(Location);
var result = await this.LocationProvider.UpdateLocationAsync(id, Location);
if (result.IsSuccess)
{
return Ok(result.ErrorMessage);
return Ok(result.Location);
}
return NotFound();
}
@ -76,9 +74,9 @@ namespace DamageAssesment.Api.Locations.Controllers
var result = await this.LocationProvider.PostLocationAsync(Location);
if (result.IsSuccess)
{
return Ok(result.Question);
return Ok(result.Location);
}
return BadRequest();
return BadRequest(result.ErrorMessage);
}
return BadRequest();
}
@ -87,12 +85,12 @@ namespace DamageAssesment.Api.Locations.Controllers
/// </summary>
[HttpDelete("Locations/{id}")]
public async Task<IActionResult> DeleteLocation(string id)
public async Task<IActionResult> DeleteLocation(int id)
{
var result = await this.LocationProvider.DeleteLocationAsync(id);
if (result.IsSuccess)
{
return Ok(result.ErrorMessage);
return Ok(result.Location);
}
return NotFound();
}

View File

@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
namespace DamageAssesment.Api.Locations.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RegionsController : ControllerBase
{
@ -17,13 +16,13 @@ namespace DamageAssesment.Api.Locations.Controllers
/// Get all regions.2
/// </summary>
[HttpGet]
[HttpGet("regions")]
public async Task<ActionResult> GetRegionsAsync()
{
var result = await regionProvider.GetRegionsAsync();
if (result.IsSuccess)
{
return Ok(result.regions);
return Ok(result.Regions);
}
return NoContent();
}
@ -31,10 +30,10 @@ namespace DamageAssesment.Api.Locations.Controllers
/// GET request for retrieving a region by its ID.
/// </summary>
[HttpGet("{Id}")]
public async Task<ActionResult> GetRegionAsync(string Id)
[HttpGet("regions/{id}")]
public async Task<ActionResult> GetRegionAsync(int id)
{
var result = await this.regionProvider.GetRegionByIdAsync(Id);
var result = await this.regionProvider.GetRegionByIdAsync(id);
if (result.IsSuccess)
{
return Ok(result.Region);
@ -45,7 +44,7 @@ namespace DamageAssesment.Api.Locations.Controllers
/// POST request for creating a new region.
/// </summary>
[HttpPost]
[HttpPost("regions")]
public async Task<ActionResult> PostRegionAsync(Models.Region region)
{
var result = await this.regionProvider.PostRegionAsync(region);
@ -59,10 +58,10 @@ namespace DamageAssesment.Api.Locations.Controllers
/// PUT request for updating an existing region.
/// </summary>
[HttpPut]
public async Task<ActionResult> PutRegionAsync(Models.Region region)
[HttpPut("regions/{id}")]
public async Task<ActionResult> PutRegionAsync(int id, Models.Region region)
{
var result = await this.regionProvider.PutRegionAsync(region);
var result = await this.regionProvider.PutRegionAsync(id,region);
if (result.IsSuccess)
{
return Ok(result.Region);
@ -77,10 +76,10 @@ namespace DamageAssesment.Api.Locations.Controllers
/// </summary>
[HttpDelete("{Id}")]
public async Task<ActionResult> DeleteRegionAsync(string Id)
[HttpDelete("regions/{id}")]
public async Task<ActionResult> DeleteRegionAsync(int id)
{
var result = await this.regionProvider.DeleteRegionAsync(Id);
var result = await this.regionProvider.DeleteRegionAsync(id);
if (result.IsSuccess)
{
return Ok(result.Region);