Multi language dynamic object changes

This commit is contained in:
uppuv
2023-09-08 15:40:06 -04:00
parent 24a6e6513e
commit 4cf7d9f891
21 changed files with 370 additions and 283 deletions

View File

@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
namespace DamageAssesment.Api.Questions.Controllers
{
[Route("api")]
[ApiController]
public class QuestionsController : ControllerBase
{
@ -21,12 +20,12 @@ namespace DamageAssesment.Api.Questions.Controllers
/// </summary>
// get all questions
[Route("{Language}/Questions")]
[Route("Questions")]
[Route("Questions/{language:alpha}")]
[HttpGet]
public async Task<IActionResult> GetQuestionsAsync(string? Language)
public async Task<IActionResult> GetQuestionsAsync(string? language)
{
var result = await this.questionsProvider.GetQuestionsAsync(Language);
var result = await this.questionsProvider.GetQuestionsAsync(language);
if (result.IsSuccess)
{
return Ok(result.Questions);
@ -38,12 +37,12 @@ namespace DamageAssesment.Api.Questions.Controllers
/// <summary>
/// GET request for retrieving a question by ID.
/// </summary>
[Route("{Language}/Questions/{id}")]
[Route("Questions/{id}")]
[Route("Questions/{id}/{language:alpha}")]
[Route("Questions/{id:int}")]
[HttpGet]
public async Task<IActionResult> GetQuestionAsync(int id, string? Language)
public async Task<IActionResult> GetQuestionByIdAsync(string? language,int id)
{
var result = await this.questionsProvider.GetQuestionAsync(id,Language);
var result = await this.questionsProvider.GetQuestionAsync(id, language);
if (result.IsSuccess)
{
return Ok(result.Question);
@ -56,12 +55,12 @@ namespace DamageAssesment.Api.Questions.Controllers
/// GET request for retrieving survey questions based on a survey ID.
/// Uri: {Optional language}/GetSurveyQuestions/{surveyId} :Default returns question in all languages
/// </summary>
[Route("{Language}/GetSurveyQuestions/{surveyId}")]
[Route("GetSurveyQuestions/{surveyId}")]
[Route("Questions/BySurvey/{surveyId:int}")]
[Route("Questions/BySurvey/{surveyId:int}/{language:alpha}")]
[HttpGet]
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? Language)
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? language)
{
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, Language);
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, language);
if (result.IsSuccess)
{
return Ok(result.SurveyQuestions);
@ -126,10 +125,11 @@ namespace DamageAssesment.Api.Questions.Controllers
/// GET request for retrieving question categories.
/// </summary>
[HttpGet("QuestionCategories")]
public async Task<IActionResult> GetQuestionCategoriesAsync()
[HttpGet("Questions/Categories")]
[HttpGet("Questions/Categories/{language:alpha}")]
public async Task<IActionResult> GetQuestionCategoriesAsync(string? language)
{
var result = await this.questionsProvider.GetQuestionCategoriesAsync();
var result = await this.questionsProvider.GetQuestionCategoriesAsync(language);
if (result.IsSuccess)
{
return Ok(result.QuestionCategories);
@ -140,10 +140,11 @@ namespace DamageAssesment.Api.Questions.Controllers
/// GET request for retrieving a question category by ID.
/// </summary>
[HttpGet("QuestionCategories/{id}")]
public async Task<IActionResult> GetQuestionCategoryAsync(int id)
[HttpGet("Questions/Categories/{id:int}")]
[HttpGet("Questions/Categories/{id:int}/{language:alpha}")]
public async Task<IActionResult> GetQuestionCategoryAsync(int id,string? language)
{
var result = await this.questionsProvider.GetQuestionCategoryAsync(id);
var result = await this.questionsProvider.GetQuestionCategoryAsync(id, language);
if (result.IsSuccess)
{
return Ok(result.QuestionCategory);
@ -156,7 +157,7 @@ namespace DamageAssesment.Api.Questions.Controllers
/// PUT request for updating a question category.
/// </summary>
[HttpPut("QuestionCategories")]
[HttpPut("Questions/Categories")]
public async Task<IActionResult> UpdateQuestionCategory(Models.QuestionCategory questionCategory)
{
if (questionCategory != null)
@ -177,7 +178,7 @@ namespace DamageAssesment.Api.Questions.Controllers
/// POST request for creating a new question category.
/// </summary>
[HttpPost("QuestionCategories")]
[HttpPost("Questions/Categories")]
public async Task<IActionResult> CreateQuestionCategory(Models.QuestionCategory questionCategory)
{
if (questionCategory != null)
@ -195,7 +196,7 @@ namespace DamageAssesment.Api.Questions.Controllers
/// DELETE request for deleting a question category based on ID.
/// </summary>
[HttpDelete("QuestionCategories/{id}")]
[HttpDelete("Questions/Categories/{id}")]
public async Task<IActionResult> DeleteQuestionCategory(int id)
{
var result = await this.questionsProvider.DeleteQuestionCategoryAsync(id);