forked from MDCPS/DamageAssessment_Backend
Multilingual support for survey and Questions
This commit is contained in:
@ -15,6 +15,9 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
{
|
||||
this.surveyProvider = surveyProvider;
|
||||
}
|
||||
/// <summary>
|
||||
/// GET request for retrieving surveys.
|
||||
/// </summary>
|
||||
|
||||
|
||||
[Route("Surveys")]
|
||||
@ -29,11 +32,20 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
[Route("Surveys/{Id}")]
|
||||
[Route("{Language}/Surveys/{Id}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSurveysAsync(int Id, string? Language)
|
||||
=======
|
||||
/// <summary>
|
||||
/// GET request for retrieving surveys by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("{Id}")]
|
||||
public async Task<ActionResult> GetSurveysAsync(int Id)
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
{
|
||||
var result = await this.surveyProvider.GetSurveysAsync(Id, Language);
|
||||
if (result.IsSuccess)
|
||||
@ -42,6 +54,9 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
/// <summary>
|
||||
/// POST request for creating a new survey.
|
||||
/// </summary>
|
||||
|
||||
[HttpPost("Surveys")]
|
||||
public async Task<ActionResult> PostSurveysAsync(Models.Survey survey)
|
||||
@ -53,6 +68,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
}
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
/// <summary>
|
||||
/// PUT request for updating an existing survey (surveyId,Updated Survey data).
|
||||
/// </summary>
|
||||
|
||||
|
||||
[HttpPut("Surveys/{Id}")]
|
||||
public async Task<ActionResult> PutSurveysAsync(int Id, Models.Survey survey)
|
||||
@ -67,8 +86,16 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
|
||||
return BadRequest(result.ErrorMessage);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
[HttpDelete("Surveys/{Id}")]
|
||||
=======
|
||||
/// <summary>
|
||||
/// DELETE request for deleting a survey by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpDelete("{Id}")]
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
public async Task<ActionResult> DeleteSurveysAsync(int Id)
|
||||
{
|
||||
var result = await this.surveyProvider.DeleteSurveyAsync(Id);
|
||||
|
@ -1,9 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -3,8 +3,12 @@ using DamageAssesment.Api.Surveys.Interfaces;
|
||||
using DamageAssesment.Api.Surveys.Providers;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
<<<<<<< HEAD
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Text;
|
||||
=======
|
||||
using System.Reflection;
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -33,7 +37,14 @@ builder.Services.AddControllers();
|
||||
builder.Services.AddScoped<ISurveyProvider, SurveysProvider>();
|
||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
//builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
// Include XML comments from your assembly
|
||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||
c.IncludeXmlComments(xmlPath);
|
||||
});
|
||||
builder.Services.AddDbContext<SurveysDbContext>(option =>
|
||||
{
|
||||
option.UseInMemoryDatabase("Surveys");
|
||||
|
Reference in New Issue
Block a user