Multilingual support for survey and Questions

This commit is contained in:
Reginald Cherenfant Jasmin 2023-08-25 09:17:53 -04:00
commit 448950ea27
31 changed files with 360 additions and 81 deletions

View File

@ -14,7 +14,10 @@ namespace DamageAssesment.Api.Answers.Controllers
public AnswersController(IAnswersProvider answersProvider) {
this.answerProvider=answersProvider;
}
//get all answers
/// <summary>
/// Get all answers
/// </summary>
[HttpGet("Answers")]
public async Task<ActionResult> GetAnswersAsync() {
@ -26,7 +29,11 @@ namespace DamageAssesment.Api.Answers.Controllers
return NoContent();
}
//get answer based on answerid
/// <summary>
/// Get an answer based on answerId.
/// </summary>
[HttpGet("Answers/{Id}")]
public async Task<ActionResult> GetAnswerByIdAsync(int Id)
{
@ -39,7 +46,9 @@ namespace DamageAssesment.Api.Answers.Controllers
return NotFound();
}
// get all answers based on response id
/// <summary>
/// Get all answers based on responseId.
/// </summary>
[HttpGet("AnswersByResponse/{ResponseId}")]
public async Task<IActionResult> GetAnswersByResponseId(int ResponseId)
{
@ -50,7 +59,10 @@ namespace DamageAssesment.Api.Answers.Controllers
}
return NoContent();
}
// get all answers based on question id
/// <summary>
/// Get all answers based on questionId.
/// </summary>
[HttpGet("AnswersByQuestion/{QuestionId}")]
public async Task<IActionResult> AnswersByQuestionId(int QuestionId)
{
@ -61,14 +73,16 @@ namespace DamageAssesment.Api.Answers.Controllers
}
return NotFound();
}
//update existing answer
/// <summary>
/// Update an existing answer.
/// </summary>
[HttpPut("Answers")]
public async Task<IActionResult> UpdateAnswer(Db.Answer answer)
public IActionResult UpdateAnswer(Db.Answer answer)
{
if (answer != null)
{
var result = await this.answerProvider.UpdateAnswerAsync(answer);
var result = this.answerProvider.UpdateAnswerAsync(answer);
if (result.IsSuccess)
{
return Ok(result.Answer);
@ -80,13 +94,16 @@ namespace DamageAssesment.Api.Answers.Controllers
}
return NotFound();
}
//save new answer
/// <summary>
/// Save a new answer.
/// </summary>
[HttpPost("Answers")]
public async Task<IActionResult> CreateAnswer(Db.Answer answer)
public IActionResult CreateAnswer(Db.Answer answer)
{
if (answer != null)
{
var result = await this.answerProvider.PostAnswerAsync(answer);
var result = this.answerProvider.PostAnswerAsync(answer);
if (result.IsSuccess)
{
return Ok(result.Answer);
@ -95,7 +112,10 @@ namespace DamageAssesment.Api.Answers.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = answer.Id }, answer);
}
//delete existing answer
/// <summary>
/// Delete an existing answer.
/// </summary>
[HttpDelete("Answers/{id}")]
public async Task<IActionResult> DeleteAnswer(int id)
{

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@ -6,8 +6,8 @@
Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersByQuestionAsync(int questionId);
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> GetAnswerByIdAsync(int Id);
Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersAsync(int responseId);
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Db.Answer Answer);
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> UpdateAnswerAsync(Db.Answer Answer);
(bool IsSuccess, Models.Answer Answer, string ErrorMessage) PostAnswerAsync(Db.Answer Answer);
(bool IsSuccess, Models.Answer Answer, string ErrorMessage) UpdateAnswerAsync(Db.Answer Answer);
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id);
}
}

View File

@ -2,6 +2,7 @@ using DamageAssesment.Api.Answers.Db;
using DamageAssesment.Api.Answers.Interfaces;
using DamageAssesment.Api.Answers.Providers;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@ -10,7 +11,14 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
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.AddScoped<IAnswersProvider, AnswersProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<AnswerDbContext>(option =>

View File

@ -108,7 +108,7 @@ namespace DamageAssesment.Api.Answers.Providers
return (false, null, ex.Message);
}
}
public async Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Db.Answer Answer)
public (bool IsSuccess, Models.Answer Answer, string ErrorMessage) PostAnswerAsync(Db.Answer Answer)
{
try
{
@ -128,7 +128,7 @@ namespace DamageAssesment.Api.Answers.Providers
return (false, null, ex.Message);
}
}
public async Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> UpdateAnswerAsync(Db.Answer Answer)
public (bool IsSuccess, Models.Answer Answer, string ErrorMessage) UpdateAnswerAsync(Db.Answer Answer)
{
try
{

View File

@ -19,7 +19,10 @@ namespace DamageAssesment.Api.Attachments.Controllers
this.AttachmentProvider = AttachmentsProvider;
this.UploadService = uploadService;
}
//get all Attachments
/// <summary>
/// Get all attachments.
/// </summary>
[HttpGet("Attachments")]
public async Task<ActionResult> GetAttachmentsAsync()
{
@ -32,7 +35,9 @@ namespace DamageAssesment.Api.Attachments.Controllers
return NoContent();
}
//get all Attachment by Id
/// <summary>
/// Get all attachments by attachmentId.
/// </summary>
[HttpGet("Attachments/{id}")]
public async Task<ActionResult> GetAttachmentbyIdAsync(int id)
{
@ -73,17 +78,20 @@ namespace DamageAssesment.Api.Attachments.Controllers
// }
//}
//Save new Attachment
/// <summary>
/// Save new Attachment(s)
/// </summary>
[HttpPost("Attachments"), DisableRequestSizeLimit]
public async Task<IActionResult> UploadAttachmentAsync(AttachmentInfo attachmentInfo)
public IActionResult UploadAttachmentAsync(AttachmentInfo attachmentInfo)
{
try
{
if (attachmentInfo.Answers.Count > 0)
{
var Attachments = await this.AttachmentProvider.GetAttachmentCounter();
var Attachments = this.AttachmentProvider.GetAttachmentCounter();
List<Db.Attachment> attachments = UploadService.UploadAttachment(attachmentInfo.ResponseId, Attachments.counter, attachmentInfo.Answers);
var result = await this.AttachmentProvider.PostAttachmentAsync(attachments);
var result = this.AttachmentProvider.PostAttachmentAsync(attachments);
if (result.IsSuccess)
{
return Ok(result.Attachments);
@ -97,20 +105,22 @@ namespace DamageAssesment.Api.Attachments.Controllers
return BadRequest($"Internal server error: {ex}");
}
}
/// <summary>
/// Modify an new attachment.
/// </summary>
//Save new Attachment
[HttpPut("Attachments"), DisableRequestSizeLimit]
public async Task<IActionResult> UpdateAttachmentAsync(AttachmentInfo attachmentInfo)
public IActionResult UpdateAttachmentAsync(AttachmentInfo attachmentInfo)
{
try
{
if (attachmentInfo.Answers.Count > 0)
{
var res = await this.AttachmentProvider.GetAttachmentInfo(attachmentInfo.Answers);
var res = this.AttachmentProvider.GetAttachmentInfo(attachmentInfo.Answers);
if (res.IsSuccess)
{
List<Db.Attachment> attachments = UploadService.UpdateAttachments(attachmentInfo.ResponseId, attachmentInfo.Answers, res.Attachments);
var result = await this.AttachmentProvider.PutAttachmentAsync(attachments);
var result = this.AttachmentProvider.PutAttachmentAsync(attachments);
if (result.IsSuccess)
{
return Ok(result.Attachments);
@ -126,7 +136,9 @@ namespace DamageAssesment.Api.Attachments.Controllers
return BadRequest($"Internal server error: {ex}");
}
}
//delete existing Attachment
/// <summary>
/// Delete an existing attachment.
/// </summary>
[HttpDelete("Delete")]
public async Task<IActionResult> DeleteAttachment(int Id)
{

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@ -6,12 +6,12 @@ namespace DamageAssesment.Api.Attachments.Interfaces
{
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync();
Task<(bool IsSuccess, Models.Attachment Attachment, string ErrorMessage)> GetAttachmentByIdAsync(int Id);
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PostAttachmentAsync(List<Db.Attachment> Attachments);
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PutAttachmentAsync(List<Db.Attachment> Attachments);
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PostAttachmentAsync(List<Db.Attachment> Attachments);
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PutAttachmentAsync(List<Db.Attachment> Attachments);
Task<(bool IsSuccess, Models.Attachment Attachment, string Path)> DeleteAttachmentAsync(int Id);
Task<(bool IsSuccess, int counter, string Path)> DeleteAttachmentsAsync(int responseId, int answerId);
Task<(bool IsSuccess, int counter, string Path)> DeleteBulkAttachmentsAsync(int responseId, List<int> answerIds);
Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter();
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentInfo(List<AnswerInfo> answers);
(bool IsSuccess, int counter, string message) GetAttachmentCounter();
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) GetAttachmentInfo(List<AnswerInfo> answers);
}
}

View File

@ -4,6 +4,7 @@ using DamageAssesment.Api.Attachments.Providers;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.FileProviders;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@ -12,7 +13,14 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
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.AddScoped<IAttachmentsProvider, AttachmentsProvider>();
builder.Services.AddScoped<IUploadService, UploadService>();
builder.Services.AddScoped<IAzureBlobService,AzureBlobService>();

View File

@ -65,7 +65,7 @@ namespace DamageAssesment.Api.Attachments.Providers
return (false, null, ex.Message);
}
}
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PostAttachmentAsync(List<Db.Attachment> Attachments)
public (bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PostAttachmentAsync(List<Db.Attachment> Attachments)
{
try
{
@ -82,7 +82,7 @@ namespace DamageAssesment.Api.Attachments.Providers
}
}
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PutAttachmentAsync(List<Db.Attachment> Attachments)
public (bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PutAttachmentAsync(List<Db.Attachment> Attachments)
{
try
{
@ -119,7 +119,7 @@ namespace DamageAssesment.Api.Attachments.Providers
return (false, AttachmentId, "");
}
}
public async Task<(bool IsSuccess,int counter,string message)> GetAttachmentCounter()
public (bool IsSuccess,int counter,string message) GetAttachmentCounter()
{
try
{
@ -152,7 +152,7 @@ namespace DamageAssesment.Api.Attachments.Providers
return (false, AttachmentId, "");
}
}
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)>GetAttachmentInfo(List<AnswerInfo> answers)
public (bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) GetAttachmentInfo(List<AnswerInfo> answers)
{
try
{

View File

@ -15,7 +15,11 @@ namespace DamageAssesment.Api.Employees.Controllers
{
this.EmployeeProvider = EmployeesProvider;
}
//get all Employees
/// <summary>
/// GET request for retrieving employees.
/// </summary>
[HttpGet("Employees")]
public async Task<ActionResult> GetEmployeesAsync()
{
@ -28,7 +32,11 @@ namespace DamageAssesment.Api.Employees.Controllers
return NoContent();
}
//get Employee based on Employeeid
/// <summary>
/// GET request for retrieving an employee by ID.
/// </summary>
[HttpGet("Employees/{Id}")]
public async Task<ActionResult> GetEmployeeByIdAsync(string Id)
{
@ -41,8 +49,11 @@ namespace DamageAssesment.Api.Employees.Controllers
return NotFound();
}
//update existing Employee
/// <summary>
/// PUT request for updating an existing employee.
/// </summary>
/// <param name="Employee">The updated employee object.</param>
[HttpPut("Employees")]
public async Task<IActionResult> UpdateEmployee(Db.Employee Employee)
{
@ -60,7 +71,11 @@ namespace DamageAssesment.Api.Employees.Controllers
}
return NotFound();
}
//save new Employee
/// <summary>
/// POST request for creating a new employee.
/// </summary>
/// <param name="Employee">The employee information for creating a new employee.</param>
[HttpPost("Employees")]
public async Task<IActionResult> CreateEmployee(Db.Employee Employee)
{
@ -75,7 +90,10 @@ namespace DamageAssesment.Api.Employees.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = Employee.Id }, Employee);
}
//delete existing Employee
/// <summary>
/// DELETE request for deleting an existing employee.
/// </summary>
/// <param name="id">The ID of the employee to be deleted.</param>
[HttpDelete("Employees/{id}")]
public async Task<IActionResult> DeleteEmployee(string id)
{

View File

@ -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>

View File

@ -2,6 +2,7 @@ using DamageAssesment.Api.Employees.Db;
using DamageAssesment.Api.Employees.Interfaces;
using DamageAssesment.Api.Employees.Providers;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@ -10,7 +11,15 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
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.AddScoped<IEmployeesProvider, EmployeesProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<EmployeeDbContext>(option =>

View File

@ -151,8 +151,8 @@ namespace DamageAssesment.Api.Employees.Providers
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp2", Name = "ABC2", Email = "abc2@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-22), IsActive = true, PreferredLanguage = "fr" });
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp3", Name = "ABC3", Email = "abc3@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-30) ,IsActive = true, PreferredLanguage = "fr" });
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp4", Name = "ABC4", Email = "abc4@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-20) ,IsActive = true, PreferredLanguage = "en" });
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp5", Name = "ABC5", Email = "abc5@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-23) ,IsActive = true, PreferredLanguage = "sp" });
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp6", Name = "ABC6", Email = "abc6@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-32) ,IsActive = true, PreferredLanguage = "sp" });
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp5", Name = "ABC5", Email = "abc5@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-23) ,IsActive = true, PreferredLanguage = "es" });
EmployeeDbContext.Employees.Add(new Db.Employee() { Id = "Emp6", Name = "ABC6", Email = "abc6@gmail.com", OfficePhoneNumber = "12345678", BirthDate = DateTime.Now.AddYears(-32) ,IsActive = true, PreferredLanguage = "es" });
EmployeeDbContext.SaveChanges();
}

View File

@ -14,7 +14,10 @@ namespace DamageAssesment.Api.Locations.Controllers
{
this.LocationProvider = LocationsProvider;
}
// Get all Locations
/// <summary>
/// Get all locations.
/// </summary>
[HttpGet("Locations")]
public async Task<ActionResult> GetLocationsAsync()
{
@ -27,7 +30,10 @@ namespace DamageAssesment.Api.Locations.Controllers
return NotFound();
}
// Get all Location based on Id
/// <summary>
/// Get all locations based on locationdId.
/// </summary>
[HttpGet("Locations/{id}")]
public async Task<ActionResult> GetLocationByIdAsync(string id)
{
@ -40,7 +46,10 @@ namespace DamageAssesment.Api.Locations.Controllers
return NotFound();
}
// Update Location entity
/// <summary>
/// Update a Location.
/// </summary>
[HttpPut("Locations")]
public async Task<IActionResult> UpdateLocation(Db.Location Location)
{
@ -55,7 +64,10 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return NotFound();
}
//save new location
/// <summary>
/// Save a new location.
/// </summary>
[HttpPost("Locations")]
public async Task<IActionResult> CreateLocation(Db.Location Location)
{
@ -70,7 +82,10 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = Location.Id }, Location);
}
//delete existing location
/// <summary>
/// Delete an existing location.
/// </summary>
[HttpDelete("Locations/{id}")]
public async Task<IActionResult> DeleteLocation(string id)
{

View File

@ -13,8 +13,10 @@ namespace DamageAssesment.Api.Locations.Controllers
{
this.regionProvider = regionProvider;
}
/// <summary>
/// Get all regions.
/// </summary>
// Get all Regions
[HttpGet]
public async Task<ActionResult> GetRegionsAsync()
{
@ -25,6 +27,9 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return NoContent();
}
/// <summary>
/// GET request for retrieving a region by its ID.
/// </summary>
[HttpGet("{Id}")]
public async Task<ActionResult> GetRegionAsync(string Id)
@ -36,6 +41,9 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return NotFound();
}
/// <summary>
/// POST request for creating a new region.
/// </summary>
[HttpPost]
public async Task<ActionResult> PostRegionAsync(Models.Region region)
@ -47,6 +55,9 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// PUT request for updating an existing region.
/// </summary>
[HttpPut]
public async Task<ActionResult> PutRegionAsync(Models.Region region)
@ -61,6 +72,10 @@ namespace DamageAssesment.Api.Locations.Controllers
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// DELETE request for deleting a region based on ID.
/// </summary>
[HttpDelete("{Id}")]
public async Task<ActionResult> DeleteRegionAsync(string Id)

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@ -2,6 +2,7 @@ using DamageAssesment.Api.Locations.Db;
using DamageAssesment.Api.Locations.Interfaces;
using DamageAssesment.Api.Locations.Providers;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@ -10,8 +11,14 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
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.AddScoped<ILocationsProvider, LocationsProvider>();
builder.Services.AddScoped<IRegionsProvider, RegionsProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30

View File

@ -15,11 +15,20 @@ namespace DamageAssesment.Api.Questions.Controllers
this.questionsProvider = questionsProvider;
}
<<<<<<< HEAD
// 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)
@ -28,11 +37,20 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return NoContent();
}
<<<<<<< HEAD
//Get questions based on question id
[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)
@ -41,10 +59,19 @@ 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
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? Language)
{
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, Language);
@ -54,7 +81,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return NotFound();
}
//update existing question
/// <summary>
/// PUT request for updating a question (multilingual).
/// </summary>
[HttpPut("Questions")]
public async Task<IActionResult> UpdateQuestion(Models.Question question)
{
@ -72,7 +102,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = question.Id }, question);
}
//save new question
/// <summary>
/// POST request for creating a new question (multilingual).
/// </summary>
[HttpPost("Questions")]
public async Task<IActionResult> CreateQuestion(Models.Question question)
{
@ -87,7 +120,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = question.Id }, question);
}
// delete existing question
/// <summary>
/// DELETE request for deleting a question based on ID.
/// </summary>
[HttpDelete("Questions/{id}")]
public async Task<IActionResult> DeleteQuestion(int id)
{
@ -100,7 +136,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
// get all questions
/// <summary>
/// GET request for retrieving question categories.
/// </summary>
[HttpGet("QuestionCategories")]
public async Task<IActionResult> GetQuestionCategoriesAsync()
{
@ -111,7 +150,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return NoContent();
}
//Get questions based on question id
/// <summary>
/// GET request for retrieving a question category by ID.
/// </summary>
[HttpGet("QuestionCategories/{id}")]
public async Task<IActionResult> GetQuestionCategoryAsync(int id)
{
@ -124,7 +166,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
//update existing question
/// <summary>
/// PUT request for updating a question category.
/// </summary>
[HttpPut("QuestionCategories")]
public async Task<IActionResult> UpdateQuestionCategory(Models.QuestionCategory questionCategory)
{
@ -142,7 +187,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = questionCategory.Id }, questionCategory);
}
//save new question
/// <summary>
/// POST request for creating a new question category.
/// </summary>
[HttpPost("QuestionCategories")]
public async Task<IActionResult> CreateQuestionCategory(Models.QuestionCategory questionCategory)
{
@ -157,7 +205,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = questionCategory.Id }, questionCategory);
}
// delete existing question
/// <summary>
/// DELETE request for deleting a question category based on ID.
/// </summary>
[HttpDelete("QuestionCategories/{id}")]
public async Task<IActionResult> DeleteQuestionCategory(int id)
{

View File

@ -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>

View File

@ -20,7 +20,6 @@ namespace DamageAssesment.Api.Questions.Db
public bool Key { get; set; }
[ForeignKey("Survey")]
public int? SurveyId { get; set; }
public string QuestionGroup { get; set; }
[ForeignKey("QuestionCategory")]
public int CategoryId { get; set; }

View File

@ -17,7 +17,6 @@ namespace DamageAssesment.Api.Questions.Models
public bool Key { get; set; }
public int? SurveyId { get; set; }
public string QuestionGroup { get; set; }
public int CategoryId { get; set; }
// public int? Survey_SurveyID { get; set; }
}

View File

@ -3,6 +3,7 @@ using DamageAssesment.Api.Questions.Interfaces;
using DamageAssesment.Api.Questions.Providers;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@ -17,7 +18,14 @@ 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<QuestionDbContext>(option =>
{
option.UseInMemoryDatabase("Questions");

View File

@ -37,35 +37,47 @@ namespace DamageAssesment.Api.Questions.Providers
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 4, QuestionId = 2, QuestionText = "Les terrains sont-ils inondés ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 5, QuestionId = 3, QuestionText = "Is the access blocked by flooding ?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 6, QuestionId = 3, QuestionText = "L'accès est-il bloqué par les inondations ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 7, QuestionId = 1, QuestionText = "Puedes abrir ?", Language = "sp" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 8, QuestionId = 2, QuestionText = "¿Están inundados los terrenos?", Language = "sp" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 9, QuestionId = 3, QuestionText = "¿El acceso está bloqueado por inundaciones?", Language = "sp" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 7, QuestionId = 1, QuestionText = "Puedes abrir ?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 8, QuestionId = 2, QuestionText = "¿Están inundados los terrenos?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { Id = 9, QuestionId = 3, QuestionText = "¿El acceso está bloqueado por inundaciones?", Language = "es" });
questionDbContext.SaveChanges();
}
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())
{
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 1, TypeText = "Text 1" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 2, TypeText = "Text 2" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 3, TypeText = "Text 3" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 4, TypeText = "Text 4" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 5, TypeText = "Text 5" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 1, TypeText = "RadioButton" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 2, TypeText = "CheckBox" });
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { Id = 3, TypeText = "TextBox" });
questionDbContext.SaveChanges();
}
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();
}

View File

@ -18,7 +18,7 @@ namespace DamageAssesment.Api.Questions.Test
for (int i = 0; i < 10; i++)
{
list.Append(new Questions.Models.Question { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, QuestionGroup = "group1",CategoryId=i });
list.Append(new Questions.Models.Question { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=i });
}
return (true, list, null);
}
@ -79,7 +79,7 @@ namespace DamageAssesment.Api.Questions.Test
};
List<Models.QuestionsTranslation> QuestionsTranslations = new List<Models.QuestionsTranslation>();
QuestionsTranslations.Add(QuestionsTranslation);
return new Questions.Models.Question { Id = 1, Questions=QuestionsTranslations, TypeText = "Text 1", SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, QuestionGroup = "group1" ,CategoryId=1};
return new Questions.Models.Question { Id = 1, Questions=QuestionsTranslations, TypeText = "Text 1", SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=1};
}

View File

@ -16,6 +16,9 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
{
this.surveyResponseProvider = surveyResponseProvider;
}
/// <summary>
/// GET request for retrieving survey responses.
/// </summary>
[HttpGet("SurveyResponses")]
public async Task<ActionResult> GetSurveyResponsesAsync()
@ -31,6 +34,9 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// GET request for retrieving survey responses by survey ID.
/// </summary>
[HttpGet("SurveyResponses/{surveyId}")]
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyId)
@ -42,6 +48,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NoContent();
}
/// <summary>
/// GET request for retrieving survey responses by survey and location IDs.
/// </summary>
/// <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, string locationId)
@ -54,6 +65,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return NoContent();
}
/// <summary>
/// GET request for retrieving survey responses by survey, question, and answer.
/// </summary>
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
/// <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("ResponsesByAnswer/{surveyId}/{questionId}/{answer}")]
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer)
@ -66,6 +83,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return NoContent();
}
/// <summary>
/// GET request for retrieving answers from survey responses by survey ID and region.
/// </summary>
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
[HttpGet("AnswersByRegion/{surveyId}")]
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyId)
@ -77,6 +98,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NoContent();
}
/// <summary>
/// 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("AnswersByMaintenanceCenter/{surveyId}")]
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyId)
@ -88,6 +113,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NoContent();
}
/// <summary>
/// GET request for retrieving a survey response by response ID.
/// </summary>
/// <param name="responseId">The ID of the survey response to be retrieved.</param>
[HttpGet("SurveyResponse/{responseId}")]
public async Task<ActionResult> GetSurveyResponseByIdAsync(int responseId)
@ -100,6 +129,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return NoContent();
}
/// <summary>
/// POST request for creating a new survey response.
/// </summary>
/// <param name="surveyResponse">The survey response object to be created.</param>
[HttpPost("SurveyResponses")]
public async Task<ActionResult> PostSurveysAsync(Models.SurveyResponse surveyResponse)
@ -111,6 +144,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// PUT request for updating an existing survey response.
/// </summary>
/// <param name="Id">The ID of the survey response to be updated.</param>
/// <param name="surveyResponse">The updated survey response object.</param>
[HttpPut("SurveyResponses/{Id}")]
public async Task<ActionResult> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse)
@ -125,6 +163,9 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// DELETE request for deleting an existing survey response.
/// </summary>
[HttpDelete("SurveyResponses/{Id}")]
public async Task<ActionResult> DeleteSurveyResponseAsync(int Id)
@ -136,6 +177,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NotFound();
}
/// <summary>
/// POST request for submitting survey with multiple answers.
/// </summary>
/// <param name="answers">The answers to be submitted for the survey.</param>
[HttpPost("SurveyResponses/Answers")]
public async Task<ActionResult> PostSurveyAnswersAsync(AnswerRequest answers)

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@ -4,6 +4,7 @@ using DamageAssesment.Api.SurveyResponses.Providers;
using Microsoft.AspNetCore.DataProtection.XmlEncryption;
using Microsoft.EntityFrameworkCore;
using Polly;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
const int maxApiCallRetries = 3;
@ -50,7 +51,14 @@ builder.Services.AddHttpClient<ISurveyServiceProvider, SurveyServiceProvider>().
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<SurveyResponseDbContext>(option =>
{
option.UseInMemoryDatabase("SurveyResponses");

View File

@ -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);

View File

@ -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>

View File

@ -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");