forked from MDCPS/DamageAssessment_Backend
Update Question and Survey to support multilingual functionnality and Make language optional in URL
This commit is contained in:
@ -1,8 +1,4 @@
|
||||
using DamageAssesment.Api.Questions.Db;
|
||||
using DamageAssesment.Api.Questions.Interfaces;
|
||||
using DamageAssesment.Api.Questions.Models;
|
||||
using DamageAssesment.Api.Questions.Providers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using DamageAssesment.Api.Questions.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DamageAssesment.Api.Questions.Controllers
|
||||
@ -20,10 +16,12 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
|
||||
}
|
||||
// get all questions
|
||||
[HttpGet("Questions")]
|
||||
public async Task<IActionResult> GetQuestionsAsync()
|
||||
[Route("{Language}/Questions")]
|
||||
[Route("Questions")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetQuestionsAsync(string? Language)
|
||||
{
|
||||
var result = await this.questionsProvider.GetQuestionsAsync();
|
||||
var result = await this.questionsProvider.GetQuestionsAsync(Language);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.Questions);
|
||||
@ -31,10 +29,12 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
return NoContent();
|
||||
}
|
||||
//Get questions based on question id
|
||||
[HttpGet("Questions/{id}")]
|
||||
public async Task<IActionResult> GetQuestionAsync(int id)
|
||||
[Route("{Language}/Questions/{id}")]
|
||||
[Route("Questions/{id}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetQuestionAsync(int id, string? Language)
|
||||
{
|
||||
var result = await this.questionsProvider.GetQuestionAsync(id);
|
||||
var result = await this.questionsProvider.GetQuestionAsync(id,Language);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result.Question);
|
||||
@ -42,10 +42,11 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
//get all questions based on survey id
|
||||
[HttpGet("GetSurveyQuestions/{surveyId}")]
|
||||
[Route("{Language}/GetSurveyQuestions/{surveyId}")]
|
||||
[Route("GetSurveyQuestions/{surveyId}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? Language)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Language)) Language = "en";
|
||||
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, Language);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
|
Reference in New Issue
Block a user