diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs index fa76fcf..d6c2cac 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs @@ -9,5 +9,6 @@ Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Models.Answer Answer); Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> UpdateAnswerAsync(Models.Answer Answer); Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id); + void SeedData(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs index 6f59c30..8659252 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs @@ -35,12 +35,21 @@ var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { - app.UseSwagger(); - app.UseSwaggerUI(options => + using (var serviceScope = app.Services.CreateScope()) { + var services = serviceScope.ServiceProvider; + var surveyProvider = services.GetRequiredService(); + surveyProvider.SeedData(); + } + app.UseSwagger(); + app.UseSwaggerUI( + options => + { + //switch for local environment + //options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); options.SwaggerEndpoint("/answers/swagger/v1/swagger.json","" ); - - }); + + } ); } app.UseAuthorization(); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs index 37a80a7..e49ba29 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs @@ -18,7 +18,7 @@ namespace DamageAssesment.Api.Answers.Providers this.answerDbContext = answerDbContext; this.logger = logger; this.mapper = mapper; - SeedData(); + //SeedData(); } public async Task<(bool IsSuccess, IEnumerable Answers, string ErrorMessage)> GetAnswersAsync() @@ -188,7 +188,7 @@ namespace DamageAssesment.Api.Answers.Providers return answerDbContext.Answers.AsNoTracking().Count(e => e.Id == id) > 0; } - private void SeedData() + public void SeedData() { if (!answerDbContext.Answers.Any()) { diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs index b2f9c8c..7cb5da3 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs @@ -42,7 +42,14 @@ var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/attachments/swagger/v1/swagger.json", ""); }); + app.UseSwaggerUI(options => { + //switch for local environment + // options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); + options.SwaggerEndpoint("/attachments/swagger/v1/swagger.json", ""); + + }); + + } app.UseAuthorization(); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Interfaces/IEmployeesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Interfaces/IEmployeesProvider.cs index 529141c..8083d2c 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Interfaces/IEmployeesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Interfaces/IEmployeesProvider.cs @@ -7,5 +7,6 @@ Task<(bool IsSuccess, Models.Employee Employee, string ErrorMessage)> PostEmployeeAsync(Models.Employee Employee); Task<(bool IsSuccess, Models.Employee Employee, string ErrorMessage)> UpdateEmployeeAsync(string Id, Models.Employee Employee); Task<(bool IsSuccess, Models.Employee Employee, string ErrorMessage)> DeleteEmployeeAsync(string Id); + void SeedData(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs index e93adf9..c0c301a 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs @@ -32,11 +32,20 @@ var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { + using (var serviceScope = app.Services.CreateScope()) + { + var services = serviceScope.ServiceProvider; + var surveyProvider = services.GetRequiredService(); + surveyProvider.SeedData(); + } + app.UseSwagger(); app.UseSwaggerUI(options => { + //switch for local environment + //options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); options.SwaggerEndpoint("/employees/swagger/v1/swagger.json", ""); - // options.RoutePrefix = ""; // Serve Swagger UI at the root URL + }); } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs index 67ca1eb..1ebc442 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Providers/EmployeesProvider.cs @@ -19,7 +19,7 @@ namespace DamageAssesment.Api.Employees.Providers this.EmployeeDbContext = EmployeeDbContext; this.logger = logger; this.mapper = mapper; - SeedData(); + // SeedData(); } public async Task<(bool IsSuccess, IEnumerable Employees, string ErrorMessage)> GetEmployeesAsync() @@ -145,7 +145,7 @@ namespace DamageAssesment.Api.Employees.Providers return EmployeeDbContext.Employees.AsNoTracking().Count(e => e.Id.ToLower() == id.ToLower()) > 0; } - private void SeedData() + public void SeedData() { if (!EmployeeDbContext.Employees.Any()) { diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs index 5100081..19941b7 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/LocationsController.cs @@ -4,7 +4,8 @@ using Microsoft.AspNetCore.Mvc; namespace DamageAssesment.Api.Locations.Controllers { - //[Route("api")] + [Route("Locations")] + //[Route("[controller]")] [ApiController] public class LocationsController : ControllerBase { @@ -18,7 +19,8 @@ namespace DamageAssesment.Api.Locations.Controllers /// Get all locations. /// - [HttpGet("Locations")] + //[HttpGet("locations")] + [HttpGet] public async Task GetLocationsAsync() { @@ -34,7 +36,7 @@ namespace DamageAssesment.Api.Locations.Controllers /// Get all locations based on locationdId. /// - [HttpGet("Locations/{id}")] + [HttpGet("{id}")] public async Task GetLocationByIdAsync(string id) { @@ -50,12 +52,12 @@ namespace DamageAssesment.Api.Locations.Controllers /// Update a Location. /// - [HttpPut("Locations")] - public async Task UpdateLocation(Models.Location Location) + [HttpPut("{locations}")] + public async Task UpdateLocation(Models.Location location) { - if (Location != null) + if (location != null) { - var result = await this.LocationProvider.UpdateLocationAsync(Location); + var result = await this.LocationProvider.UpdateLocationAsync(location); if (result.IsSuccess) { return Ok(result.ErrorMessage); @@ -68,7 +70,7 @@ namespace DamageAssesment.Api.Locations.Controllers /// Save a new location. /// - [HttpPost("Locations")] + [HttpPost("{locations}")] public async Task CreateLocation(Models.Location Location) { if (Location != null) @@ -86,7 +88,7 @@ namespace DamageAssesment.Api.Locations.Controllers /// Delete an existing location. /// - [HttpDelete("Locations/{id}")] + [HttpDelete("{id}")] public async Task DeleteLocation(string id) { var result = await this.LocationProvider.DeleteLocationAsync(id); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs index aca9e18..97eafb2 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Controllers/RegionsController.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; namespace DamageAssesment.Api.Locations.Controllers { //[Route("api/[controller]")] + [Route("[controller]")] [ApiController] public class RegionsController : ControllerBase { @@ -45,7 +46,7 @@ namespace DamageAssesment.Api.Locations.Controllers /// POST request for creating a new region. /// - [HttpPost] + [HttpPost("{region}")] public async Task PostRegionAsync(Models.Region region) { var result = await this.regionProvider.PostRegionAsync(region); @@ -59,7 +60,7 @@ namespace DamageAssesment.Api.Locations.Controllers /// PUT request for updating an existing region. /// - [HttpPut] + [HttpPut("{region}")] public async Task PutRegionAsync(Models.Region region) { var result = await this.regionProvider.PutRegionAsync(region); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/ILocationsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/ILocationsProvider.cs index ff0ee55..55b847b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/ILocationsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/ILocationsProvider.cs @@ -9,5 +9,6 @@ namespace DamageAssesment.Api.Locations.Interfaces Task<(bool IsSuccess, Models.Location Question, string ErrorMessage)> PostLocationAsync(Models.Location Location); Task<(bool IsSuccess, string ErrorMessage)> UpdateLocationAsync(Models.Location Location); Task<(bool IsSuccess, string ErrorMessage)> DeleteLocationAsync(string Id); + void SeedData(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/IRegionsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/IRegionsProvider.cs index 1df0776..65f8d0b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/IRegionsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Interfaces/IRegionsProvider.cs @@ -7,5 +7,6 @@ Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> PostRegionAsync(Models.Region region); Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> PutRegionAsync(Models.Region region); Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> DeleteRegionAsync(string Id); + void SeedData(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs index 9430df5..46ea009 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs @@ -31,10 +31,24 @@ var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { + using (var serviceScope = app.Services.CreateScope()) + { + var services = serviceScope.ServiceProvider; + var locationProvider = services.GetRequiredService(); + var regionProvider = services.GetRequiredService(); + locationProvider.SeedData(); + regionProvider.SeedData(); + } + + app.UseSwagger(); app.UseSwaggerUI(options => { - options.SwaggerEndpoint("/locations/swagger/v1/swagger.json", ""); + //switch for local environment + //options.SwaggerEndpoint("/swagger/v1/swagger.json",""); + options.SwaggerEndpoint("locations/swagger/v1/swagger.json", ""); + + }); } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/LocationsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/LocationsProvider.cs index cf0e978..85da34c 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/LocationsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/LocationsProvider.cs @@ -17,7 +17,7 @@ namespace DamageAssesment.Api.Locations.Providers this.locationDbContext = locationDbContext; this.logger = logger; this.mapper = mapper; - SeedData(); + //SeedData(); } public async Task<(bool IsSuccess, IEnumerable locations, string ErrorMessage)> GetLocationsAsync() @@ -127,7 +127,7 @@ namespace DamageAssesment.Api.Locations.Providers { return locationDbContext.Locations.AsNoTracking().Count(e => e.Id == id) > 0; } - private void SeedData() + public void SeedData() { if (!locationDbContext.Locations.Any()) { diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/RegionsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/RegionsProvider.cs index 9d78ce7..a6f6c75 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/RegionsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Providers/RegionsProvider.cs @@ -17,7 +17,7 @@ namespace DamageAssesment.Api.Locations.Providers this.locationDbContext = regionDbContext; this.logger = logger; this.mapper = mapper; - SeedData(); + // SeedData(); } public async Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> GetRegionByIdAsync(string Id) @@ -150,7 +150,7 @@ namespace DamageAssesment.Api.Locations.Providers } } - private void SeedData() + public void SeedData() { if (!locationDbContext.Regions.Any()) { diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionTypeProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionTypeProvider.cs index 74df172..8e5894d 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionTypeProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionTypeProvider.cs @@ -4,5 +4,6 @@ { Task<(bool IsSuccess, Db.QuestionType QuestionType, string ErrorMessage)> GetQuestionTypeAsync(int Id); Task<(bool IsSuccess, IEnumerable QuestionTypes, string ErrorMessage)> GetQuestionTypesAsync(); + } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionsProvider.cs index 43aa2e3..58def79 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Interfaces/IQuestionsProvider.cs @@ -17,5 +17,6 @@ namespace DamageAssesment.Api.Questions.Interfaces Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> PostQuestionCategoryAsync(Models.QuestionCategory QuestionCategory); Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> UpdateQuestionCategoryAsync(Models.QuestionCategory QuestionCategory); Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> DeleteQuestionCategoryAsync(int Id); + void SeedData(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs index d388395..32465f2 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs @@ -35,8 +35,20 @@ var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { + using (var serviceScope = app.Services.CreateScope()) + { + var services = serviceScope.ServiceProvider; + var questionProvider = services.GetRequiredService(); + questionProvider.SeedData(); + } + app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/questions/swagger/v1/swagger.json", ""); }); + app.UseSwaggerUI(options => { + //switch for local environment + options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); + // options.SwaggerEndpoint("/questions/swagger/v1/swagger.json", ""); + + }); } app.UseAuthorization(); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs index 719fb5f..aa8e290 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Providers/QuestionsProvider.cs @@ -21,10 +21,10 @@ namespace DamageAssesment.Api.Questions.Providers this.questionDbContext = questionDbContext; this.logger = logger; this.mapper = mapper; - SeedData(); + // SeedData(); } - private void SeedData() + public void SeedData() { if (!questionDbContext.QuestionsTranslations.Any()) diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs index 9a52fa1..1f4dbd2 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; namespace DamageAssesment.Api.SurveyResponses.Controllers { - //[Route("api")] + [Route("Responses")] [ApiController] public class SurveyResponsesController : ControllerBase { @@ -20,7 +20,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// GET request for retrieving survey responses. /// - [HttpGet("SurveyResponses")] + [HttpGet] public async Task GetSurveyResponsesAsync() { var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(); @@ -38,7 +38,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// GET request for retrieving survey responses by survey ID. /// - [HttpGet("SurveyResponses/{surveyId}")] + [HttpGet("{surveyId}")] public async Task GetSurveyResponsesAsync(int surveyId) { var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyId); @@ -54,7 +54,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// 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}")] + [HttpGet("{surveyId}/{locationId}")] public async Task GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, string locationId) { var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyId, locationId); @@ -72,7 +72,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// 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}")] + [HttpGet("ByAnswers/{surveyId}/{questionId}/{answer}")] public async Task GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer) { var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyId, questionId, answer); @@ -88,7 +88,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The ID of the survey for which answers are to be retrieved. - [HttpGet("AnswersByRegion/{surveyId}")] + [HttpGet("ByRegion/{surveyId}")] public async Task GetAnswersByRegionAsync(int surveyId) { var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyId); @@ -103,7 +103,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The ID of the survey for which responses are to be retrieved. - [HttpGet("AnswersByMaintenanceCenter/{surveyId}")] + [HttpGet("ByMaintenanceCenter/{surveyId}")] public async Task GetAnswersByMaintenaceCentersync(int surveyId) { var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyId); @@ -118,7 +118,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The ID of the survey response to be retrieved. - [HttpGet("SurveyResponse/{responseId}")] + [HttpGet("{responseId}")] public async Task GetSurveyResponseByIdAsync(int responseId) { var result = await this.surveyResponseProvider.GetSurveyResponseByIdAsync(responseId); @@ -134,7 +134,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The survey response object to be created. - [HttpPost("SurveyResponses")] + [HttpPost] public async Task PostSurveysAsync(Models.SurveyResponse surveyResponse) { var result = await this.surveyResponseProvider.PostSurveyResponseAsync(surveyResponse); @@ -150,7 +150,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// The ID of the survey response to be updated. /// The updated survey response object. - [HttpPut("SurveyResponses/{Id}")] + [HttpPut("{Id}")] public async Task PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse) { var result = await this.surveyResponseProvider.PutSurveyResponseAsync(Id, surveyResponse); @@ -167,7 +167,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// DELETE request for deleting an existing survey response. /// - [HttpDelete("SurveyResponses/{Id}")] + [HttpDelete("{Id}")] public async Task DeleteSurveyResponseAsync(int Id) { var result = await this.surveyResponseProvider.DeleteSurveyResponseAsync(Id); @@ -182,7 +182,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The answers to be submitted for the survey. - [HttpPost("SurveyResponses/Answers")] + [HttpPost("Answers")] public async Task PostSurveyAnswersAsync(Request request) { /* var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(surveyAnswers); diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs index 1f1e9be..4500c54 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs @@ -70,7 +70,12 @@ var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/surveyresponses/swagger/v1/swagger.json", ""); }); + app.UseSwaggerUI(options => { + //switch for local environment + options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); + // options.SwaggerEndpoint("/surveyresponses/swagger/v1/swagger.json", ""); + + }); } app.UseAuthorization(); diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AnswerServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AnswerServiceProvider.cs index cb638bc..dc0e29e 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AnswerServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AnswerServiceProvider.cs @@ -29,13 +29,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var answers = JsonConvert.DeserializeObject>(responseString); if (answers == null || !answers.Any()) - return null; + return new List(); else return answers; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: AnswerServiceProvider.getAnswersAsync()"); - return null; + return new List(); } } @@ -45,19 +45,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { httpClient.BaseAddress = new Uri(urlBase); - var response = await httpClient.GetAsync("/api/AnswersByResponse/" + responseId); + var response = await httpClient.GetAsync("/AnswersByResponse/" + responseId); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); var answers = JsonConvert.DeserializeObject>(responseString); if (answers == null || !answers.Any()) - return null; + return new List(); else return answers; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: AnswerServiceProvider.GetAnswersByResponseId()"); - return null; + return new List(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AttachmentServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AttachmentServiceProvider.cs index 04f8121..e374924 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AttachmentServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/AttachmentServiceProvider.cs @@ -12,7 +12,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { public class AttachmentServiceProvider : ServiceProviderBase, IAttachmentServiceProvider { - public AttachmentServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/api/Attachments", configuration.GetValue("EndPointSettings:AttachmentUrlBase")) + public AttachmentServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/Attachments", configuration.GetValue("EndPointSettings:AttachmentUrlBase")) { } @@ -27,13 +27,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var attachments = JsonConvert.DeserializeObject>(responseString); if (attachments == null || !attachments.Any()) - return null; + return new List(); else return attachments; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: AttachmentServiceProvider.getAttachmentsAsync()"); - return null; + return new List(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/EmployeeServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/EmployeeServiceProvider.cs index faf31ff..6bef3ac 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/EmployeeServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/EmployeeServiceProvider.cs @@ -8,7 +8,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { public class EmployeeServiceProvider :ServiceProviderBase, IEmployeeServiceProvider { - public EmployeeServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/api/Employees", configuration.GetValue("EndPointSettings:EmployeeUrlBase")) + public EmployeeServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/Employees", configuration.GetValue("EndPointSettings:EmployeeUrlBase")) { } @@ -23,13 +23,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var employees = JsonConvert.DeserializeObject>(responseString); if (employees == null || !employees.Any()) - return null; + return new List(); else return employees; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: EmployeeServiceProvider.getEmployeesAsync()"); - return null; + return new List(); } } @@ -39,7 +39,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { httpClient.BaseAddress = new Uri(urlBase); //ressource = ressource + "/" + employeeID; - var response = await httpClient.GetAsync("/api/Employees/"+ employeeID); + var response = await httpClient.GetAsync("/Employees/"+ employeeID); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); var employee = JsonConvert.DeserializeObject(responseString); diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/LocationServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/LocationServiceProvider.cs index d5c9161..6c795ca 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/LocationServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/LocationServiceProvider.cs @@ -7,7 +7,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider { - public LocationServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/api/Locations", configuration.GetValue("EndPointSettings:LocationUrlBase")) + public LocationServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/Locations", configuration.GetValue("EndPointSettings:LocationUrlBase")) { } @@ -22,13 +22,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var locations = JsonConvert.DeserializeObject>(responseString); if (locations == null || !locations.Any()) - return null; + return new List(); else return locations; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: LocationServiceProvider.getLocationsAsync()"); - return null; + return new List(); } } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/QuestionServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/QuestionServiceProvider.cs index 2d9e915..0a0a3be 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/QuestionServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/QuestionServiceProvider.cs @@ -9,7 +9,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { public class QuestionServiceProvider : ServiceProviderBase, IQuestionServiceProvider { - public QuestionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/api/Questions", configuration.GetValue("EndPointSettings:QuestionUrlBase")) + public QuestionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/Questions", configuration.GetValue("EndPointSettings:QuestionUrlBase")) { } @@ -24,13 +24,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var questions = JsonConvert.DeserializeObject>(responseString); if (questions == null || !questions.Any()) - return null; + return new List(); else return questions; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: QuestionServiceProvider.getQuestionsAsync()"); - return null; + return new List(); } } @@ -39,19 +39,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers try { httpClient.BaseAddress = new Uri(urlBase); - var response = await httpClient.GetAsync("/api/GetSurveyQuestions/" + surveyId); + var response = await httpClient.GetAsync("/GetSurveyQuestions/" + surveyId); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); var questions = JsonConvert.DeserializeObject>(responseString); if (questions == null || !questions.Any()) - return null; + return new List(); else return questions; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: QuestionServiceProvider.getSurveyQuestionsAsync()"); - return null; + return new List(); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/RegionServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/RegionServiceProvider.cs index a435081..5c5c25e 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/RegionServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/RegionServiceProvider.cs @@ -7,7 +7,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { public class RegionServiceProvider : ServiceProviderBase, IRegionServiceProvider { - public RegionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/api/Regions", configuration.GetValue("EndPointSettings:LocationUrlBase")) + public RegionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/Regions", configuration.GetValue("EndPointSettings:LocationUrlBase")) { } public async Task> getRegionsAsync() @@ -21,13 +21,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var regions = JsonConvert.DeserializeObject>(responseString); if (regions == null || !regions.Any()) - return null; + return new List(); else return regions; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: RegionServiceProvider.getRegionsAsync()"); - return null; + return new List(); } } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs index 98c138d..d138294 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs @@ -37,7 +37,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers this.surveyServiceProvider = surveyServiceProvider; this.mapper = mapper; - seedData(); + //seedData(); } private void seedData() diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyServiceProvider.cs index 06b1eed..ba31eca 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyServiceProvider.cs @@ -8,7 +8,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider { - public SurveyServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/api/Surveys", configuration.GetValue("EndPointSettings:SurveyUrlBase")) + public SurveyServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger logger) : base(configuration, httpClient, logger, "/Surveys", configuration.GetValue("EndPointSettings:SurveyUrlBase")) { } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs index 0338575..81aca11 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs @@ -18,14 +18,14 @@ namespace DamageAssesment.Api.Surveys.Controllers /// GET request for retrieving surveys /// /// - /// This endpoint retrieves surveys. You can use it to get all surveys or surveys for a specific language. + /// This endpoint retrieves surveys. You can use it to get all surveys or surveys for a specific language(optional). /// [Route("Surveys")] - [Route("{Language}/Surveys")] + [Route("{language}/Surveys")] [HttpGet] - public async Task GetSurveysAsync(string? Language) + public async Task GetSurveysAsync(string? language) { - var result = await this.surveyProvider.GetSurveysAsync(Language); + var result = await this.surveyProvider.GetSurveysAsync(language); if (result.IsSuccess) { return Ok(result.Surveys); @@ -37,11 +37,11 @@ namespace DamageAssesment.Api.Surveys.Controllers /// GET request for retrieving surveys by ID. /// [Route("Surveys/{Id}")] - [Route("{Language}/Surveys/{Id}")] + [Route("{language}/Surveys/{Id}")] [HttpGet] - public async Task GetSurveysAsync(int Id, string? Language) + public async Task GetSurveysAsync(int Id, string? language) { - var result = await this.surveyProvider.GetSurveysAsync(Id, Language); + var result = await this.surveyProvider.GetSurveysAsync(Id, language); if (result.IsSuccess) { return Ok(result.Surveys); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs index e4ceb43..7b6dbdd 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs @@ -53,7 +53,12 @@ var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/survey/swagger/v1/swagger.json", ""); }); + app.UseSwaggerUI(options => { + //switch for local environment + options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); + // options.SwaggerEndpoint("/surveys/swagger/v1/swagger.json", ""); + + }); } app.UseAuthentication();