From 9345ee2ca52c4ffcd4cfab7e7ec869088ea882b5 Mon Sep 17 00:00:00 2001 From: uppuv Date: Tue, 22 Aug 2023 17:05:51 -0400 Subject: [PATCH 1/3] Removed QuestionGroup from the Question model and from the db entity --- .../Providers/EmployeesProvider.cs | 4 +-- .../Db/Question.cs | 1 - .../Models/Question.cs | 1 - .../Providers/QuestionsProvider.cs | 30 +++++++++---------- .../MockData.cs | 4 +-- 5 files changed, 18 insertions(+), 22 deletions(-) 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.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/Providers/QuestionsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs index 647f640..565a16b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs @@ -37,35 +37,33 @@ 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()) { - 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 }); 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()) { - 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" }); 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}; } From e56ffae1a4b2e332be3a8839db66b81c6e0dbda5 Mon Sep 17 00:00:00 2001 From: Santhosh S <913341@dadeschools.net> Date: Thu, 24 Aug 2023 21:25:38 -0400 Subject: [PATCH 2/3] Swagger Documentation Enhancement (273) --- .../Controllers/AnswersController.cs | 34 ++++++++--- .../DamageAssesment.Api.Answers.csproj | 1 + .../DamageAssesment.Api.Answers/Program.cs | 10 +++- .../Controllers/AttachmentsController.cs | 22 ++++++-- .../DamageAssesment.Api.Attachments.csproj | 1 + .../Program.cs | 10 +++- .../Controllers/EmployeesController.cs | 30 ++++++++-- .../DamageAssesment.Api.Employees.csproj | 3 +- .../DamageAssesment.Api.Employees/Program.cs | 11 +++- .../Controllers/LocationsController.cs | 25 +++++++-- .../Controllers/RegionsController.cs | 17 +++++- .../DamageAssesment.Api.Locations.csproj | 1 + .../DamageAssesment.Api.Locations/Program.cs | 11 +++- .../Controllers/QuestionsController.cs | 56 +++++++++++++++---- .../DamageAssesment.Api.Questions.csproj | 3 +- .../DamageAssesment.Api.Questions/Program.cs | 10 +++- .../Controllers/SurveyResponsesController.cs | 49 +++++++++++++++- ...DamageAssesment.Api.SurveyResponses.csproj | 1 + .../Program.cs | 10 +++- .../Controllers/SurveysController.cs | 19 ++++++- .../DamageAssesment.Api.Survey.csproj | 3 +- .../DamageAssesment.Api.Surveys/Program.cs | 10 +++- 22 files changed, 288 insertions(+), 49 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs index 27f5c3c..a8fefff 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,7 +73,9 @@ namespace DamageAssesment.Api.Answers.Controllers } return NotFound(); } - //update existing answer + /// + /// Update an existing answer. + /// [HttpPut("Answers")] public async Task UpdateAnswer(Db.Answer answer) @@ -80,7 +94,10 @@ namespace DamageAssesment.Api.Answers.Controllers } return NotFound(); } - //save new answer + /// + /// Save a new answer. + /// + [HttpPost("Answers")] public async Task CreateAnswer(Db.Answer 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 ca5ee38..b60fc33 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/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.Attachments/Controllers/AttachmentsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs index a86a151..11cec22 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,7 +78,10 @@ namespace DamageAssesment.Api.Attachments.Controllers // } //} - //Save new Attachment + /// + /// Save new Attachment(s) + /// + [HttpPost("Attachments"), DisableRequestSizeLimit] public async Task UploadAttachmentAsync(AttachmentInfo attachmentInfo) { @@ -97,8 +105,10 @@ 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) { @@ -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 3454bff..846a5c2 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/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.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 53e8700..7f05c71 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.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 47751c7..7f05c71 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 0184d72..2519941 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Controllers/QuestionsController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Controllers/QuestionsController.cs @@ -19,7 +19,10 @@ namespace DamageAssesment.Api.Questions.Controllers this.questionsProvider = questionsProvider; } - // get all questions + /// + /// GET request for retrieving questions. + /// + [HttpGet("Questions")] public async Task GetQuestionsAsync() { @@ -30,7 +33,10 @@ namespace DamageAssesment.Api.Questions.Controllers } return NoContent(); } - //Get questions based on question id + /// + /// GET request for retrieving a question by ID. + /// + [HttpGet("Questions/{id}")] public async Task GetQuestionAsync(int id) { @@ -41,7 +47,11 @@ namespace DamageAssesment.Api.Questions.Controllers } return NotFound(); } - //get all questions based on survey id + /// + /// 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}")] public async Task GetSurveyQuestions(int surveyId,string? Language) { @@ -53,7 +63,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) { @@ -71,7 +84,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) { @@ -86,7 +102,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) { @@ -99,7 +118,10 @@ namespace DamageAssesment.Api.Questions.Controllers } - // get all questions + /// + /// GET request for retrieving question categories. + /// + [HttpGet("QuestionCategories")] public async Task GetQuestionCategoriesAsync() { @@ -110,7 +132,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) { @@ -123,7 +148,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) { @@ -141,7 +169,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) { @@ -156,7 +187,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 53e8700..7f05c71 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/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.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 a2383fa..aae62bb 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 56f2e29..7644a69 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs @@ -14,6 +14,9 @@ namespace DamageAssesment.Api.Surveys.Controllers { this.surveyProvider = surveyProvider; } + /// + /// GET request for retrieving surveys. + /// [HttpGet] public async Task GetSurveysAsync() @@ -25,6 +28,10 @@ namespace DamageAssesment.Api.Surveys.Controllers } return NoContent(); } + /// + /// GET request for retrieving surveys by ID. + /// + [HttpGet("{Id}")] public async Task GetSurveysAsync(int Id) { @@ -35,6 +42,9 @@ namespace DamageAssesment.Api.Surveys.Controllers } return NotFound(); } + /// + /// POST request for creating a new survey. + /// [HttpPost] public async Task PostSurveysAsync(Models.Survey survey) @@ -46,6 +56,10 @@ namespace DamageAssesment.Api.Surveys.Controllers } return BadRequest(result.ErrorMessage); } + /// + /// PUT request for updating an existing survey (surveyId,Updated Survey data). + /// + [HttpPut("{Id}")] public async Task PutSurveysAsync(int Id, Models.Survey survey) @@ -60,7 +74,10 @@ namespace DamageAssesment.Api.Surveys.Controllers return BadRequest(result.ErrorMessage); } - + /// + /// DELETE request for deleting a survey by ID. + /// + [HttpDelete("{Id}")] public async Task DeleteSurveysAsync(int Id) { diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj b/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj index 53e8700..7f05c71 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 ebb638f..f59b686 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs @@ -2,6 +2,7 @@ using DamageAssesment.Api.Surveys.Db; using DamageAssesment.Api.Surveys.Interfaces; using DamageAssesment.Api.Surveys.Providers; using Microsoft.EntityFrameworkCore; +using System.Reflection; var builder = WebApplication.CreateBuilder(args); @@ -12,7 +13,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"); From cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c Mon Sep 17 00:00:00 2001 From: uppuv Date: Fri, 25 Aug 2023 07:20:37 -0400 Subject: [PATCH 3/3] Completed sync call for answer and attachment put and post methods --- .../Controllers/AnswersController.cs | 8 ++++---- .../Interfaces/IAnswersProvider.cs | 4 ++-- .../Providers/AnswerProvider.cs | 4 ++-- .../Controllers/AttachmentsController.cs | 12 ++++++------ .../Interfaces/IAttachmentsProvider.cs | 8 ++++---- .../Providers/AttachmentsProvider.cs | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs index a8fefff..95b2aab 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs @@ -78,11 +78,11 @@ namespace DamageAssesment.Api.Answers.Controllers /// [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); @@ -99,11 +99,11 @@ namespace DamageAssesment.Api.Answers.Controllers /// [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); 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/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 11cec22..745db41 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs @@ -83,15 +83,15 @@ namespace DamageAssesment.Api.Attachments.Controllers /// [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); @@ -110,17 +110,17 @@ namespace DamageAssesment.Api.Attachments.Controllers /// [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); 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/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 {