forked from MDCPS/DamageAssessment_Backend
Add EmployeeId as filter in the endpoints, add endpoints to get all active and historical surveys for a particular employee
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
using DamageAssesment.Api.SurveyResponses.Interfaces;
|
||||
using DamageAssesment.Api.SurveyResponses.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
{
|
||||
@ -19,10 +17,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// GET request for retrieving survey responses.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Responses")]
|
||||
public async Task<ActionResult> GetSurveyResponsesAsync()
|
||||
[Route("Responses/{employeeid:int}")]
|
||||
[Route("Responses")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSurveyResponsesAsync(int? employeeid)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesAsync();
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(employeeid ?? 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.surveyResponses);
|
||||
@ -36,11 +36,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// <summary>
|
||||
/// GET request for retrieving survey responses by survey ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Responses/BySurvey/{surveyid}")]
|
||||
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyid)
|
||||
[Route("Responses/BySurvey/{surveyid:int}/{employeeid:int}")]
|
||||
[Route("Responses/BySurvey/{surveyid:int}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyid, int? employeeid)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid);
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid, employeeid ?? 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.SurveyResponses);
|
||||
@ -53,15 +54,16 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// <param name="surveyid">The ID of the survey for which responses are to be retrieved.</param>
|
||||
/// <param name="locationid">The ID of the location for which responses are to be retrieved.</param>
|
||||
|
||||
[HttpGet("Responses/{surveyid}/{locationid}")]
|
||||
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyid, int locationid)
|
||||
[Route("Responses/{surveyid:int}/{locationid:int}/{employeeid:int}")]
|
||||
[Route("Responses/{surveyid:int}/{locationid:int}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyid, int locationid,int? employeeid)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyid, locationid);
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyid, locationid,employeeid ?? 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.SurveyResponses);
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
/// <summary>
|
||||
@ -71,10 +73,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
||||
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
||||
|
||||
[HttpGet("Responses/ByAnswer/{surveyid}/{questionid}/{answer}")]
|
||||
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer)
|
||||
{
|
||||
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer);
|
||||
[Route("Responses/ByAnswer/{surveyid:int}/{questionid:int}/{answer:alpha}/{employeeid:int}")]
|
||||
[Route("Responses/ByAnswer/{surveyid:int}/{questionid:int}/{answer:alpha}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer, int? employeeid)
|
||||
{
|
||||
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer, employeeid ?? 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.SurveyResponses);
|
||||
@ -87,10 +91,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// </summary>
|
||||
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
||||
|
||||
[HttpGet("Responses/ByRegion/{surveyid}")]
|
||||
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyid)
|
||||
[Route("Responses/ByRegion/{surveyid:int}")]
|
||||
[Route("Responses/ByRegion/{surveyid:int}/{employeeid}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyid, int? employeeid)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid);
|
||||
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid, employeeid ?? 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.Answers);
|
||||
@ -101,11 +107,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// GET request for retrieving survey responses by survey ID and maintenance center.
|
||||
/// </summary>
|
||||
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
||||
|
||||
[HttpGet("Responses/ByMaintenanceCenter/{surveyid}")]
|
||||
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyid)
|
||||
[Route("Responses/ByMaintenanceCenter/{surveyid:int}/{employeeid:int}")]
|
||||
[Route("Responses/ByMaintenanceCenter/{surveyid:int}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyid, int? employeeid)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid);
|
||||
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid, employeeid ?? 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.SurveyResponses);
|
||||
@ -165,7 +172,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
/// <summary>
|
||||
/// DELETE request for deleting an existing survey response.
|
||||
/// </summary>
|
||||
|
||||
|
||||
[HttpDelete("Responses/{id}")]
|
||||
public async Task<ActionResult> DeleteSurveyResponseAsync(int id)
|
||||
{
|
||||
@ -191,5 +198,31 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||
else
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
|
||||
[Route("Responses/Surveys/active/{employeeid:int}")]
|
||||
[Route("Responses/Surveys/active/{employeeid:int}/{language:alpha}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetActiveSurveysAsync(int employeeid, string? language)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetActiveSurveysAsync(employeeid, language);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.Surveys);
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[Route("Responses/Surveys/historic/{employeeid:int}")]
|
||||
[Route("Responses/Surveys/historic/{employeeid:int}/{language:alpha}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetHistoricSurveysAsync(int employeeid, string? language)
|
||||
{
|
||||
var result = await this.surveyResponseProvider.GetHistoricSurveysAsync(employeeid, language);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.Surveys);
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user