forked from MDCPS/DamageAssessment_Backend
Multi Language support
This commit is contained in:
@ -15,20 +15,16 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
this.questionsProvider = questionsProvider;
|
||||
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
/// <summary>
|
||||
/// GET request for retrieving questions.
|
||||
/// </summary>
|
||||
|
||||
// get all questions
|
||||
[Route("{Language}/Questions")]
|
||||
[Route("Questions")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetQuestionsAsync(string? Language)
|
||||
=======
|
||||
/// <summary>
|
||||
/// GET request for retrieving questions.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Questions")]
|
||||
public async Task<IActionResult> GetQuestionsAsync()
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
{
|
||||
var result = await this.questionsProvider.GetQuestionsAsync(Language);
|
||||
if (result.IsSuccess)
|
||||
@ -37,20 +33,15 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
//Get questions based on question id
|
||||
/// <summary>
|
||||
/// GET request for retrieving a question by ID.
|
||||
/// </summary>
|
||||
[Route("{Language}/Questions/{id}")]
|
||||
[Route("Questions/{id}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetQuestionAsync(int id, string? Language)
|
||||
=======
|
||||
/// <summary>
|
||||
/// GET request for retrieving a question by ID.
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("Questions/{id}")]
|
||||
public async Task<IActionResult> GetQuestionAsync(int id)
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
{
|
||||
var result = await this.questionsProvider.GetQuestionAsync(id,Language);
|
||||
if (result.IsSuccess)
|
||||
@ -59,19 +50,15 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
//get all questions based on survey id
|
||||
[Route("{Language}/GetSurveyQuestions/{surveyId}")]
|
||||
[Route("GetSurveyQuestions/{surveyId}")]
|
||||
[HttpGet]
|
||||
=======
|
||||
/// <summary>
|
||||
/// GET request for retrieving survey questions based on a survey ID.
|
||||
/// Uri: {Optional language}/GetSurveyQuestions/{surveyId} :Default returns question in all languages
|
||||
/// </summary>
|
||||
|
||||
[HttpGet("GetSurveyQuestions/{surveyId}")]
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
[Route("{Language}/GetSurveyQuestions/{surveyId}")]
|
||||
[Route("GetSurveyQuestions/{surveyId}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? Language)
|
||||
{
|
||||
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, Language);
|
||||
@ -135,7 +122,6 @@ namespace DamageAssesment.Api.Questions.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// GET request for retrieving question categories.
|
||||
/// </summary>
|
||||
|
@ -24,8 +24,6 @@ namespace DamageAssesment.Api.Questions.Providers
|
||||
SeedData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SeedData()
|
||||
{
|
||||
|
||||
@ -44,15 +42,9 @@ namespace DamageAssesment.Api.Questions.Providers
|
||||
}
|
||||
if (!questionDbContext.Questions.Any())
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
questionDbContext.Questions.Add(new Db.Question() { Id = 1, QuestionTypeId = 2, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, QuestionGroup = "group1", CategoryId = 1 });
|
||||
questionDbContext.Questions.Add(new Db.Question() { Id = 2, QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, QuestionGroup = "group1", CategoryId = 1 });
|
||||
questionDbContext.Questions.Add(new Db.Question() { Id = 3, QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 3, IsRequired = true, Comment = false, Key = true, QuestionGroup = "group1", CategoryId = 2 });
|
||||
=======
|
||||
questionDbContext.Questions.Add(new Db.Question() { Id = 1, QuestionTypeId = 2, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=1 });
|
||||
questionDbContext.Questions.Add(new Db.Question() { Id = 2, QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 1 });
|
||||
questionDbContext.Questions.Add(new Db.Question() { Id = 3, QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 3, IsRequired = true, Comment = false, Key = true, CategoryId = 2 });
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
questionDbContext.SaveChanges();
|
||||
}
|
||||
if (!questionDbContext.QuestionTypes.Any())
|
||||
@ -65,22 +57,13 @@ namespace DamageAssesment.Api.Questions.Providers
|
||||
|
||||
if (!questionDbContext.QuestionCategories.Any())
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 1, CategoryName = "Category 1", CategoryImage = "img1" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 2, CategoryName = "Category 2", CategoryImage = "img1" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 3, CategoryName = "Category 3", CategoryImage = "img1" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 4, CategoryName = "Category 4", CategoryImage = "img1" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 5, CategoryName = "Category 5", CategoryImage = "img1" });
|
||||
=======
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 1, CategoryName = "Flooding", CategoryImage= "https://example.com/images/img1.png" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 2, CategoryName = "Electrical", CategoryImage = "https://example.com/images/img2.png" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 3, CategoryName = "Structural", CategoryImage = "https://example.com/images/img3.png" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 4, CategoryName = "Utility", CategoryImage = "https://example.com/images/img4.png" });
|
||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 5, CategoryName = "Debris", CategoryImage = "https://example.com/images/img5.png" });
|
||||
>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
|
||||
questionDbContext.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<(bool IsSuccess, IEnumerable<Models.Question> Questions, string ErrorMessage)> GetQuestionsAsync(string Language)
|
||||
@ -273,8 +256,6 @@ namespace DamageAssesment.Api.Questions.Providers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Question Category Logic
|
||||
|
||||
public async Task<(bool IsSuccess, IEnumerable<Models.QuestionCategory> QuestionCategories, string ErrorMessage)> GetQuestionCategoriesAsync()
|
||||
|
Reference in New Issue
Block a user