diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs
index 27f5c3c..95b2aab 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs
@@ -14,7 +14,10 @@ namespace DamageAssesment.Api.Answers.Controllers
public AnswersController(IAnswersProvider answersProvider) {
this.answerProvider=answersProvider;
}
- //get all answers
+ ///
+ /// Get all answers
+ ///
+
[HttpGet("Answers")]
public async Task GetAnswersAsync() {
@@ -26,7 +29,11 @@ namespace DamageAssesment.Api.Answers.Controllers
return NoContent();
}
- //get answer based on answerid
+ ///
+ /// Get an answer based on answerId.
+ ///
+
+
[HttpGet("Answers/{Id}")]
public async Task GetAnswerByIdAsync(int Id)
{
@@ -39,7 +46,9 @@ namespace DamageAssesment.Api.Answers.Controllers
return NotFound();
}
- // get all answers based on response id
+ ///
+ /// Get all answers based on responseId.
+ ///
[HttpGet("AnswersByResponse/{ResponseId}")]
public async Task GetAnswersByResponseId(int ResponseId)
{
@@ -50,7 +59,10 @@ namespace DamageAssesment.Api.Answers.Controllers
}
return NoContent();
}
- // get all answers based on question id
+ ///
+ /// Get all answers based on questionId.
+ ///
+
[HttpGet("AnswersByQuestion/{QuestionId}")]
public async Task AnswersByQuestionId(int QuestionId)
{
@@ -61,14 +73,16 @@ namespace DamageAssesment.Api.Answers.Controllers
}
return NotFound();
}
- //update existing answer
+ ///
+ /// Update an existing answer.
+ ///
[HttpPut("Answers")]
- public async Task 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
+ ///
+ /// Save a new answer.
+ ///
+
[HttpPost("Answers")]
- public async Task 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
+ ///
+ /// Delete an existing answer.
+ ///
+
[HttpDelete("Answers/{id}")]
public async Task DeleteAnswer(int id)
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj b/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj
index 260a911..f33241f 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj
@@ -4,6 +4,7 @@
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs
index 4a202f1..4b5fcc1 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs
@@ -6,8 +6,8 @@
Task<(bool IsSuccess, IEnumerable Answers, string ErrorMessage)> GetAnswersByQuestionAsync(int questionId);
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> GetAnswerByIdAsync(int Id);
Task<(bool IsSuccess, IEnumerable 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);
}
}
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs
index 7630089..373d300 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs
@@ -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();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext(option =>
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs
index b1851d8..f7f2268 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs
@@ -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
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs
index a86a151..745db41 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs
@@ -19,7 +19,10 @@ namespace DamageAssesment.Api.Attachments.Controllers
this.AttachmentProvider = AttachmentsProvider;
this.UploadService = uploadService;
}
- //get all Attachments
+ ///
+ /// Get all attachments.
+ ///
+
[HttpGet("Attachments")]
public async Task GetAttachmentsAsync()
{
@@ -32,7 +35,9 @@ namespace DamageAssesment.Api.Attachments.Controllers
return NoContent();
}
- //get all Attachment by Id
+ ///
+ /// Get all attachments by attachmentId.
+ ///
[HttpGet("Attachments/{id}")]
public async Task GetAttachmentbyIdAsync(int id)
{
@@ -73,17 +78,20 @@ namespace DamageAssesment.Api.Attachments.Controllers
// }
//}
- //Save new Attachment
+ ///
+ /// Save new Attachment(s)
+ ///
+
[HttpPost("Attachments"), DisableRequestSizeLimit]
- public async Task 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 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}");
}
}
+ ///
+ /// Modify an new attachment.
+ ///
- //Save new Attachment
[HttpPut("Attachments"), DisableRequestSizeLimit]
- public async Task 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 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
+ ///
+ /// Delete an existing attachment.
+ ///
[HttpDelete("Delete")]
public async Task DeleteAttachment(int Id)
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj b/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj
index 4d9cb44..46a5b7a 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj
@@ -4,6 +4,7 @@
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs
index f193e11..81bc749 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs
@@ -6,12 +6,12 @@ namespace DamageAssesment.Api.Attachments.Interfaces
{
Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> GetAttachmentsAsync();
Task<(bool IsSuccess, Models.Attachment Attachment, string ErrorMessage)> GetAttachmentByIdAsync(int Id);
- Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PostAttachmentAsync(List Attachments);
- Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PutAttachmentAsync(List Attachments);
+ (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PostAttachmentAsync(List Attachments);
+ (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PutAttachmentAsync(List 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 answerIds);
- Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter();
- Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> GetAttachmentInfo(List answers);
+ (bool IsSuccess, int counter, string message) GetAttachmentCounter();
+ (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) GetAttachmentInfo(List answers);
}
}
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs
index d661ef6..61ce1c5 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs
@@ -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();
builder.Services.AddScoped();
builder.Services.AddScoped();
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs
index 6a3cc63..aa42d93 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs
@@ -65,7 +65,7 @@ namespace DamageAssesment.Api.Attachments.Providers
return (false, null, ex.Message);
}
}
- public async Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PostAttachmentAsync(List Attachments)
+ public (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PostAttachmentAsync(List Attachments)
{
try
{
@@ -82,7 +82,7 @@ namespace DamageAssesment.Api.Attachments.Providers
}
}
- public async Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PutAttachmentAsync(List Attachments)
+ public (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PutAttachmentAsync(List 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 Attachments, string ErrorMessage)>GetAttachmentInfo(List answers)
+ public (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) GetAttachmentInfo(List answers)
{
try
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Controllers/EmployeesController.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Controllers/EmployeesController.cs
index 192a9d0..a074f21 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Controllers/EmployeesController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Controllers/EmployeesController.cs
@@ -15,7 +15,11 @@ namespace DamageAssesment.Api.Employees.Controllers
{
this.EmployeeProvider = EmployeesProvider;
}
- //get all Employees
+
+ ///
+ /// GET request for retrieving employees.
+ ///
+
[HttpGet("Employees")]
public async Task GetEmployeesAsync()
{
@@ -28,7 +32,11 @@ namespace DamageAssesment.Api.Employees.Controllers
return NoContent();
}
- //get Employee based on Employeeid
+
+ ///
+ /// GET request for retrieving an employee by ID.
+ ///
+
[HttpGet("Employees/{Id}")]
public async Task GetEmployeeByIdAsync(string Id)
{
@@ -41,8 +49,11 @@ namespace DamageAssesment.Api.Employees.Controllers
return NotFound();
}
- //update existing Employee
-
+
+ ///
+ /// PUT request for updating an existing employee.
+ ///
+ /// The updated employee object.
[HttpPut("Employees")]
public async Task UpdateEmployee(Db.Employee Employee)
{
@@ -60,7 +71,11 @@ namespace DamageAssesment.Api.Employees.Controllers
}
return NotFound();
}
- //save new Employee
+
+ ///
+ /// POST request for creating a new employee.
+ ///
+ /// The employee information for creating a new employee.
[HttpPost("Employees")]
public async Task CreateEmployee(Db.Employee Employee)
{
@@ -75,7 +90,10 @@ namespace DamageAssesment.Api.Employees.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = Employee.Id }, Employee);
}
- //delete existing Employee
+ ///
+ /// DELETE request for deleting an existing employee.
+ ///
+ /// The ID of the employee to be deleted.
[HttpDelete("Employees/{id}")]
public async Task DeleteEmployee(string id)
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj b/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj
index 515ad43..a696247 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj
@@ -1,9 +1,10 @@
-
+
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs
index 29b91fa..7d5dbff 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs
@@ -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();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext(option =>
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs
index b2ec99b..8e31e82 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs
@@ -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();
}
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs
index c1df10f..040bd93 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs
@@ -14,7 +14,10 @@ namespace DamageAssesment.Api.Locations.Controllers
{
this.LocationProvider = LocationsProvider;
}
- // Get all Locations
+ ///
+ /// Get all locations.
+ ///
+
[HttpGet("Locations")]
public async Task GetLocationsAsync()
{
@@ -27,7 +30,10 @@ namespace DamageAssesment.Api.Locations.Controllers
return NotFound();
}
- // Get all Location based on Id
+ ///
+ /// Get all locations based on locationdId.
+ ///
+
[HttpGet("Locations/{id}")]
public async Task GetLocationByIdAsync(string id)
{
@@ -40,7 +46,10 @@ namespace DamageAssesment.Api.Locations.Controllers
return NotFound();
}
- // Update Location entity
+ ///
+ /// Update a Location.
+ ///
+
[HttpPut("Locations")]
public async Task UpdateLocation(Db.Location Location)
{
@@ -55,7 +64,10 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return NotFound();
}
- //save new location
+ ///
+ /// Save a new location.
+ ///
+
[HttpPost("Locations")]
public async Task CreateLocation(Db.Location Location)
{
@@ -70,7 +82,10 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = Location.Id }, Location);
}
- //delete existing location
+ ///
+ /// Delete an existing location.
+ ///
+
[HttpDelete("Locations/{id}")]
public async Task DeleteLocation(string id)
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs
index 64a9bc7..81725e4 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs
@@ -13,8 +13,10 @@ namespace DamageAssesment.Api.Locations.Controllers
{
this.regionProvider = regionProvider;
}
+ ///
+ /// Get all regions.
+ ///
- // Get all Regions
[HttpGet]
public async Task GetRegionsAsync()
{
@@ -25,6 +27,9 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return NoContent();
}
+ ///
+ /// GET request for retrieving a region by its ID.
+ ///
[HttpGet("{Id}")]
public async Task GetRegionAsync(string Id)
@@ -36,6 +41,9 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return NotFound();
}
+ ///
+ /// POST request for creating a new region.
+ ///
[HttpPost]
public async Task PostRegionAsync(Models.Region region)
@@ -47,6 +55,9 @@ namespace DamageAssesment.Api.Locations.Controllers
}
return BadRequest(result.ErrorMessage);
}
+ ///
+ /// PUT request for updating an existing region.
+ ///
[HttpPut]
public async Task PutRegionAsync(Models.Region region)
@@ -61,6 +72,10 @@ namespace DamageAssesment.Api.Locations.Controllers
return BadRequest(result.ErrorMessage);
}
+ ///
+ /// DELETE request for deleting a region based on ID.
+ ///
+
[HttpDelete("{Id}")]
public async Task DeleteRegionAsync(string Id)
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj b/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj
index 5264699..a696247 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj
@@ -4,6 +4,7 @@
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs
index a2e3149..c152e61 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs
@@ -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();
builder.Services.AddScoped();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Controllers/QuestionsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Controllers/QuestionsController.cs
index d376c20..7c0ba52 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Controllers/QuestionsController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Controllers/QuestionsController.cs
@@ -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 GetQuestionsAsync(string? Language)
+=======
+ ///
+ /// GET request for retrieving questions.
+ ///
+
+ [HttpGet("Questions")]
+ public async Task 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 GetQuestionAsync(int id, string? Language)
+=======
+ ///
+ /// GET request for retrieving a question by ID.
+ ///
+
+ [HttpGet("Questions/{id}")]
+ public async Task 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]
+=======
+ ///
+ /// GET request for retrieving survey questions based on a survey ID.
+ /// Uri: {Optional language}/GetSurveyQuestions/{surveyId} :Default returns question in all languages
+ ///
+
+ [HttpGet("GetSurveyQuestions/{surveyId}")]
+>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
public async Task 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
+ ///
+ /// PUT request for updating a question (multilingual).
+ ///
+
[HttpPut("Questions")]
public async Task UpdateQuestion(Models.Question question)
{
@@ -72,7 +102,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = question.Id }, question);
}
- //save new question
+ ///
+ /// POST request for creating a new question (multilingual).
+ ///
+
[HttpPost("Questions")]
public async Task CreateQuestion(Models.Question question)
{
@@ -87,7 +120,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = question.Id }, question);
}
- // delete existing question
+ ///
+ /// DELETE request for deleting a question based on ID.
+ ///
+
[HttpDelete("Questions/{id}")]
public async Task DeleteQuestion(int id)
{
@@ -100,7 +136,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
- // get all questions
+ ///
+ /// GET request for retrieving question categories.
+ ///
+
[HttpGet("QuestionCategories")]
public async Task GetQuestionCategoriesAsync()
{
@@ -111,7 +150,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return NoContent();
}
- //Get questions based on question id
+ ///
+ /// GET request for retrieving a question category by ID.
+ ///
+
[HttpGet("QuestionCategories/{id}")]
public async Task GetQuestionCategoryAsync(int id)
{
@@ -124,7 +166,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
- //update existing question
+ ///
+ /// PUT request for updating a question category.
+ ///
+
[HttpPut("QuestionCategories")]
public async Task UpdateQuestionCategory(Models.QuestionCategory questionCategory)
{
@@ -142,7 +187,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = questionCategory.Id }, questionCategory);
}
- //save new question
+ ///
+ /// POST request for creating a new question category.
+ ///
+
[HttpPost("QuestionCategories")]
public async Task CreateQuestionCategory(Models.QuestionCategory questionCategory)
{
@@ -157,7 +205,10 @@ namespace DamageAssesment.Api.Questions.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = questionCategory.Id }, questionCategory);
}
- // delete existing question
+ ///
+ /// DELETE request for deleting a question category based on ID.
+ ///
+
[HttpDelete("QuestionCategories/{id}")]
public async Task DeleteQuestionCategory(int id)
{
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj b/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj
index 515ad43..a696247 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj
@@ -1,9 +1,10 @@
-
+
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Db/Question.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Db/Question.cs
index 846df86..29d0c64 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Db/Question.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Db/Question.cs
@@ -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; }
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Models/Question.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Models/Question.cs
index e181f1f..b694f5b 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Models/Question.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Models/Question.cs
@@ -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; }
}
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs
index 3774b0b..321c989 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs
@@ -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(option =>
{
option.UseInMemoryDatabase("Questions");
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs
index f684a9f..7baea60 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs
@@ -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();
}
diff --git a/DamageAssesmentApi/DamageAssesment.Api.QuestionsTest/MockData.cs b/DamageAssesmentApi/DamageAssesment.Api.QuestionsTest/MockData.cs
index f9c0c87..be919ed 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.QuestionsTest/MockData.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.QuestionsTest/MockData.cs
@@ -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 QuestionsTranslations = new List();
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};
}
diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs
index 42b29dc..b3ff885 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs
@@ -16,6 +16,9 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
{
this.surveyResponseProvider = surveyResponseProvider;
}
+ ///
+ /// GET request for retrieving survey responses.
+ ///
[HttpGet("SurveyResponses")]
public async Task GetSurveyResponsesAsync()
@@ -31,7 +34,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return BadRequest(result.ErrorMessage);
}
-
+ ///
+ /// GET request for retrieving survey responses by survey ID.
+ ///
+
[HttpGet("SurveyResponses/{surveyId}")]
public async Task GetSurveyResponsesAsync(int surveyId)
{
@@ -42,6 +48,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NoContent();
}
+ ///
+ /// GET request for retrieving survey responses by survey and location IDs.
+ ///
+ /// The ID of the survey for which responses are to be retrieved.
+ /// The ID of the location for which responses are to be retrieved.
[HttpGet("Responses/{surveyId}/{locationId}")]
public async Task GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, string locationId)
@@ -54,6 +65,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return NoContent();
}
+ ///
+ /// GET request for retrieving survey responses by survey, question, and answer.
+ ///
+ /// The ID of the survey for which responses are to be retrieved.
+ /// The ID of the question for which responses are to be retrieved.
+ /// The answer for which responses are to be retrieved.
[HttpGet("ResponsesByAnswer/{surveyId}/{questionId}/{answer}")]
public async Task GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer)
@@ -66,6 +83,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return NoContent();
}
+ ///
+ /// GET request for retrieving answers from survey responses by survey ID and region.
+ ///
+ /// The ID of the survey for which answers are to be retrieved.
[HttpGet("AnswersByRegion/{surveyId}")]
public async Task GetAnswersByRegionAsync(int surveyId)
@@ -77,6 +98,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NoContent();
}
+ ///
+ /// GET request for retrieving survey responses by survey ID and maintenance center.
+ ///
+ /// The ID of the survey for which responses are to be retrieved.
[HttpGet("AnswersByMaintenanceCenter/{surveyId}")]
public async Task GetAnswersByMaintenaceCentersync(int surveyId)
@@ -88,6 +113,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NoContent();
}
+ ///
+ /// GET request for retrieving a survey response by response ID.
+ ///
+ /// The ID of the survey response to be retrieved.
[HttpGet("SurveyResponse/{responseId}")]
public async Task GetSurveyResponseByIdAsync(int responseId)
@@ -100,6 +129,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return NoContent();
}
+ ///
+ /// POST request for creating a new survey response.
+ ///
+ /// The survey response object to be created.
[HttpPost("SurveyResponses")]
public async Task PostSurveysAsync(Models.SurveyResponse surveyResponse)
@@ -111,6 +144,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return BadRequest(result.ErrorMessage);
}
+ ///
+ /// PUT request for updating an existing survey response.
+ ///
+ /// The ID of the survey response to be updated.
+ /// The updated survey response object.
[HttpPut("SurveyResponses/{Id}")]
public async Task PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse)
@@ -125,7 +163,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
return BadRequest(result.ErrorMessage);
}
-
+ ///
+ /// DELETE request for deleting an existing survey response.
+ ///
+
[HttpDelete("SurveyResponses/{Id}")]
public async Task DeleteSurveyResponseAsync(int Id)
{
@@ -136,6 +177,10 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
}
return NotFound();
}
+ ///
+ /// POST request for submitting survey with multiple answers.
+ ///
+ /// The answers to be submitted for the survey.
[HttpPost("SurveyResponses/Answers")]
public async Task PostSurveyAnswersAsync(AnswerRequest answers)
diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj
index fec1ec5..02ef277 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj
@@ -4,6 +4,7 @@
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs
index b94d753..a4f585f 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs
@@ -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().
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(option =>
{
option.UseInMemoryDatabase("SurveyResponses");
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs
index 3115228..f98a3e0 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs
@@ -15,6 +15,9 @@ namespace DamageAssesment.Api.Surveys.Controllers
{
this.surveyProvider = surveyProvider;
}
+ ///
+ /// GET request for retrieving surveys.
+ ///
[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 GetSurveysAsync(int Id, string? Language)
+=======
+ ///
+ /// GET request for retrieving surveys by ID.
+ ///
+
+ [HttpGet("{Id}")]
+ public async Task 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();
}
+ ///
+ /// POST request for creating a new survey.
+ ///
[HttpPost("Surveys")]
public async Task PostSurveysAsync(Models.Survey survey)
@@ -53,6 +68,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
}
return BadRequest(result.ErrorMessage);
}
+ ///
+ /// PUT request for updating an existing survey (surveyId,Updated Survey data).
+ ///
+
[HttpPut("Surveys/{Id}")]
public async Task PutSurveysAsync(int Id, Models.Survey survey)
@@ -67,8 +86,16 @@ namespace DamageAssesment.Api.Surveys.Controllers
return BadRequest(result.ErrorMessage);
}
+<<<<<<< HEAD
[HttpDelete("Surveys/{Id}")]
+=======
+ ///
+ /// DELETE request for deleting a survey by ID.
+ ///
+
+ [HttpDelete("{Id}")]
+>>>>>>> cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c
public async Task DeleteSurveysAsync(int Id)
{
var result = await this.surveyProvider.DeleteSurveyAsync(Id);
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj b/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
index 515ad43..a696247 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
+++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
@@ -1,9 +1,10 @@
-
+
net6.0
enable
enable
+ True
diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs
index 91e052c..7368a72 100644
--- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs
+++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs
@@ -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();
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(option =>
{
option.UseInMemoryDatabase("Surveys");