Fix for Data seed issue,Url Correction for SurveyResponses
This commit is contained in:
parent
af004ce565
commit
a52f6e0cf9
@ -9,5 +9,6 @@
|
|||||||
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Models.Answer Answer);
|
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)> UpdateAnswerAsync(Models.Answer Answer);
|
||||||
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id);
|
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id);
|
||||||
|
void SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,21 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
app.UseSwaggerUI(options =>
|
|
||||||
{
|
{
|
||||||
|
var services = serviceScope.ServiceProvider;
|
||||||
|
var surveyProvider = services.GetRequiredService<IAnswersProvider>();
|
||||||
|
surveyProvider.SeedData();
|
||||||
|
}
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(
|
||||||
|
options =>
|
||||||
|
{
|
||||||
|
//switch for local environment
|
||||||
|
//options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
||||||
options.SwaggerEndpoint("/answers/swagger/v1/swagger.json","" );
|
options.SwaggerEndpoint("/answers/swagger/v1/swagger.json","" );
|
||||||
|
|
||||||
});
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -18,7 +18,7 @@ namespace DamageAssesment.Api.Answers.Providers
|
|||||||
this.answerDbContext = answerDbContext;
|
this.answerDbContext = answerDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
SeedData();
|
//SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersAsync()
|
||||||
@ -188,7 +188,7 @@ namespace DamageAssesment.Api.Answers.Providers
|
|||||||
return answerDbContext.Answers.AsNoTracking().Count(e => e.Id == id) > 0;
|
return answerDbContext.Answers.AsNoTracking().Count(e => e.Id == id) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SeedData()
|
public void SeedData()
|
||||||
{
|
{
|
||||||
if (!answerDbContext.Answers.Any())
|
if (!answerDbContext.Answers.Any())
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,14 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
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();
|
app.UseAuthorization();
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
Task<(bool IsSuccess, Models.Employee Employee, string ErrorMessage)> PostEmployeeAsync(Models.Employee Employee);
|
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)> UpdateEmployeeAsync(string Id, Models.Employee Employee);
|
||||||
Task<(bool IsSuccess, Models.Employee Employee, string ErrorMessage)> DeleteEmployeeAsync(string Id);
|
Task<(bool IsSuccess, Models.Employee Employee, string ErrorMessage)> DeleteEmployeeAsync(string Id);
|
||||||
|
void SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,20 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var services = serviceScope.ServiceProvider;
|
||||||
|
var surveyProvider = services.GetRequiredService<IEmployeesProvider>();
|
||||||
|
surveyProvider.SeedData();
|
||||||
|
}
|
||||||
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(options =>
|
app.UseSwaggerUI(options =>
|
||||||
{
|
{
|
||||||
|
//switch for local environment
|
||||||
|
//options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
||||||
options.SwaggerEndpoint("/employees/swagger/v1/swagger.json", "");
|
options.SwaggerEndpoint("/employees/swagger/v1/swagger.json", "");
|
||||||
// options.RoutePrefix = ""; // Serve Swagger UI at the root URL
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace DamageAssesment.Api.Employees.Providers
|
|||||||
this.EmployeeDbContext = EmployeeDbContext;
|
this.EmployeeDbContext = EmployeeDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
SeedData();
|
// SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Employee> Employees, string ErrorMessage)> GetEmployeesAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.Employee> 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;
|
return EmployeeDbContext.Employees.AsNoTracking().Count(e => e.Id.ToLower() == id.ToLower()) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SeedData()
|
public void SeedData()
|
||||||
{
|
{
|
||||||
if (!EmployeeDbContext.Employees.Any())
|
if (!EmployeeDbContext.Employees.Any())
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Locations.Controllers
|
namespace DamageAssesment.Api.Locations.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
[Route("Locations")]
|
||||||
|
//[Route("[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class LocationsController : ControllerBase
|
public class LocationsController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -18,7 +19,8 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Get all locations.
|
/// Get all locations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("Locations")]
|
//[HttpGet("locations")]
|
||||||
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetLocationsAsync()
|
public async Task<ActionResult> GetLocationsAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Get all locations based on locationdId.
|
/// Get all locations based on locationdId.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("Locations/{id}")]
|
[HttpGet("{id}")]
|
||||||
public async Task<ActionResult> GetLocationByIdAsync(string id)
|
public async Task<ActionResult> GetLocationByIdAsync(string id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -50,12 +52,12 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Update a Location.
|
/// Update a Location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut("Locations")]
|
[HttpPut("{locations}")]
|
||||||
public async Task<IActionResult> UpdateLocation(Models.Location Location)
|
public async Task<IActionResult> 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)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.ErrorMessage);
|
return Ok(result.ErrorMessage);
|
||||||
@ -68,7 +70,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Save a new location.
|
/// Save a new location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("Locations")]
|
[HttpPost("{locations}")]
|
||||||
public async Task<IActionResult> CreateLocation(Models.Location Location)
|
public async Task<IActionResult> CreateLocation(Models.Location Location)
|
||||||
{
|
{
|
||||||
if (Location != null)
|
if (Location != null)
|
||||||
@ -86,7 +88,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Delete an existing location.
|
/// Delete an existing location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpDelete("Locations/{id}")]
|
[HttpDelete("{id}")]
|
||||||
public async Task<IActionResult> DeleteLocation(string id)
|
public async Task<IActionResult> DeleteLocation(string id)
|
||||||
{
|
{
|
||||||
var result = await this.LocationProvider.DeleteLocationAsync(id);
|
var result = await this.LocationProvider.DeleteLocationAsync(id);
|
||||||
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
namespace DamageAssesment.Api.Locations.Controllers
|
namespace DamageAssesment.Api.Locations.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api/[controller]")]
|
//[Route("api/[controller]")]
|
||||||
|
[Route("[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class RegionsController : ControllerBase
|
public class RegionsController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -45,7 +46,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// POST request for creating a new region.
|
/// POST request for creating a new region.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost("{region}")]
|
||||||
public async Task<ActionResult> PostRegionAsync(Models.Region region)
|
public async Task<ActionResult> PostRegionAsync(Models.Region region)
|
||||||
{
|
{
|
||||||
var result = await this.regionProvider.PostRegionAsync(region);
|
var result = await this.regionProvider.PostRegionAsync(region);
|
||||||
@ -59,7 +60,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// PUT request for updating an existing region.
|
/// PUT request for updating an existing region.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut]
|
[HttpPut("{region}")]
|
||||||
public async Task<ActionResult> PutRegionAsync(Models.Region region)
|
public async Task<ActionResult> PutRegionAsync(Models.Region region)
|
||||||
{
|
{
|
||||||
var result = await this.regionProvider.PutRegionAsync(region);
|
var result = await this.regionProvider.PutRegionAsync(region);
|
||||||
|
@ -9,5 +9,6 @@ namespace DamageAssesment.Api.Locations.Interfaces
|
|||||||
Task<(bool IsSuccess, Models.Location Question, string ErrorMessage)> PostLocationAsync(Models.Location Location);
|
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)> UpdateLocationAsync(Models.Location Location);
|
||||||
Task<(bool IsSuccess, string ErrorMessage)> DeleteLocationAsync(string Id);
|
Task<(bool IsSuccess, string ErrorMessage)> DeleteLocationAsync(string Id);
|
||||||
|
void SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> PostRegionAsync(Models.Region region);
|
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)> PutRegionAsync(Models.Region region);
|
||||||
Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> DeleteRegionAsync(string Id);
|
Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> DeleteRegionAsync(string Id);
|
||||||
|
void SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,24 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var services = serviceScope.ServiceProvider;
|
||||||
|
var locationProvider = services.GetRequiredService<ILocationsProvider>();
|
||||||
|
var regionProvider = services.GetRequiredService<IRegionsProvider>();
|
||||||
|
locationProvider.SeedData();
|
||||||
|
regionProvider.SeedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(options =>
|
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", "");
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace DamageAssesment.Api.Locations.Providers
|
|||||||
this.locationDbContext = locationDbContext;
|
this.locationDbContext = locationDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
SeedData();
|
//SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Location> locations, string ErrorMessage)> GetLocationsAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.Location> locations, string ErrorMessage)> GetLocationsAsync()
|
||||||
@ -127,7 +127,7 @@ namespace DamageAssesment.Api.Locations.Providers
|
|||||||
{
|
{
|
||||||
return locationDbContext.Locations.AsNoTracking().Count(e => e.Id == id) > 0;
|
return locationDbContext.Locations.AsNoTracking().Count(e => e.Id == id) > 0;
|
||||||
}
|
}
|
||||||
private void SeedData()
|
public void SeedData()
|
||||||
{
|
{
|
||||||
if (!locationDbContext.Locations.Any())
|
if (!locationDbContext.Locations.Any())
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace DamageAssesment.Api.Locations.Providers
|
|||||||
this.locationDbContext = regionDbContext;
|
this.locationDbContext = regionDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
SeedData();
|
// SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> GetRegionByIdAsync(string Id)
|
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())
|
if (!locationDbContext.Regions.Any())
|
||||||
{
|
{
|
||||||
|
@ -4,5 +4,6 @@
|
|||||||
{
|
{
|
||||||
Task<(bool IsSuccess, Db.QuestionType QuestionType, string ErrorMessage)> GetQuestionTypeAsync(int Id);
|
Task<(bool IsSuccess, Db.QuestionType QuestionType, string ErrorMessage)> GetQuestionTypeAsync(int Id);
|
||||||
Task<(bool IsSuccess, IEnumerable<Db.QuestionType> QuestionTypes, string ErrorMessage)> GetQuestionTypesAsync();
|
Task<(bool IsSuccess, IEnumerable<Db.QuestionType> QuestionTypes, string ErrorMessage)> GetQuestionTypesAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)> PostQuestionCategoryAsync(Models.QuestionCategory QuestionCategory);
|
||||||
Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> UpdateQuestionCategoryAsync(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);
|
Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> DeleteQuestionCategoryAsync(int Id);
|
||||||
|
void SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,20 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var services = serviceScope.ServiceProvider;
|
||||||
|
var questionProvider = services.GetRequiredService<IQuestionsProvider>();
|
||||||
|
questionProvider.SeedData();
|
||||||
|
}
|
||||||
|
|
||||||
app.UseSwagger();
|
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();
|
app.UseAuthorization();
|
||||||
|
@ -21,10 +21,10 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
this.questionDbContext = questionDbContext;
|
this.questionDbContext = questionDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
SeedData();
|
// SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SeedData()
|
public void SeedData()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!questionDbContext.QuestionsTranslations.Any())
|
if (!questionDbContext.QuestionsTranslations.Any())
|
||||||
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
[Route("Responses")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class SurveyResponsesController : ControllerBase
|
public class SurveyResponsesController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// GET request for retrieving survey responses.
|
/// GET request for retrieving survey responses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("SurveyResponses")]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetSurveyResponsesAsync()
|
public async Task<ActionResult> GetSurveyResponsesAsync()
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.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.
|
/// GET request for retrieving survey responses by survey ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("SurveyResponses/{surveyId}")]
|
[HttpGet("{surveyId}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyId)
|
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyId);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyId);
|
||||||
@ -54,7 +54,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
||||||
/// <param name="locationId">The ID of the location for which responses are to be retrieved.</param>
|
/// <param name="locationId">The ID of the location for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("Responses/{surveyId}/{locationId}")]
|
[HttpGet("{surveyId}/{locationId}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, string locationId)
|
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, string locationId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyId, locationId);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyId, locationId);
|
||||||
@ -72,7 +72,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
||||||
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("ResponsesByAnswer/{surveyId}/{questionId}/{answer}")]
|
[HttpGet("ByAnswers/{surveyId}/{questionId}/{answer}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer)
|
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer)
|
||||||
{
|
{
|
||||||
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyId, questionId, answer);
|
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyId, questionId, answer);
|
||||||
@ -88,7 +88,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("AnswersByRegion/{surveyId}")]
|
[HttpGet("ByRegion/{surveyId}")]
|
||||||
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyId)
|
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyId);
|
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyId);
|
||||||
@ -103,7 +103,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("AnswersByMaintenanceCenter/{surveyId}")]
|
[HttpGet("ByMaintenanceCenter/{surveyId}")]
|
||||||
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyId)
|
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyId);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyId);
|
||||||
@ -118,7 +118,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="responseId">The ID of the survey response to be retrieved.</param>
|
/// <param name="responseId">The ID of the survey response to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("SurveyResponse/{responseId}")]
|
[HttpGet("{responseId}")]
|
||||||
public async Task<ActionResult> GetSurveyResponseByIdAsync(int responseId)
|
public async Task<ActionResult> GetSurveyResponseByIdAsync(int responseId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponseByIdAsync(responseId);
|
var result = await this.surveyResponseProvider.GetSurveyResponseByIdAsync(responseId);
|
||||||
@ -134,7 +134,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyResponse">The survey response object to be created.</param>
|
/// <param name="surveyResponse">The survey response object to be created.</param>
|
||||||
|
|
||||||
[HttpPost("SurveyResponses")]
|
[HttpPost]
|
||||||
public async Task<ActionResult> PostSurveysAsync(Models.SurveyResponse surveyResponse)
|
public async Task<ActionResult> PostSurveysAsync(Models.SurveyResponse surveyResponse)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.PostSurveyResponseAsync(surveyResponse);
|
var result = await this.surveyResponseProvider.PostSurveyResponseAsync(surveyResponse);
|
||||||
@ -150,7 +150,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="Id">The ID of the survey response to be updated.</param>
|
/// <param name="Id">The ID of the survey response to be updated.</param>
|
||||||
/// <param name="surveyResponse">The updated survey response object.</param>
|
/// <param name="surveyResponse">The updated survey response object.</param>
|
||||||
|
|
||||||
[HttpPut("SurveyResponses/{Id}")]
|
[HttpPut("{Id}")]
|
||||||
public async Task<ActionResult> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse)
|
public async Task<ActionResult> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.PutSurveyResponseAsync(Id, 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.
|
/// DELETE request for deleting an existing survey response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpDelete("SurveyResponses/{Id}")]
|
[HttpDelete("{Id}")]
|
||||||
public async Task<ActionResult> DeleteSurveyResponseAsync(int Id)
|
public async Task<ActionResult> DeleteSurveyResponseAsync(int Id)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.DeleteSurveyResponseAsync(Id);
|
var result = await this.surveyResponseProvider.DeleteSurveyResponseAsync(Id);
|
||||||
@ -182,7 +182,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The answers to be submitted for the survey.</param>
|
/// <param name="request">The answers to be submitted for the survey.</param>
|
||||||
|
|
||||||
[HttpPost("SurveyResponses/Answers")]
|
[HttpPost("Answers")]
|
||||||
public async Task<ActionResult> PostSurveyAnswersAsync(Request request)
|
public async Task<ActionResult> PostSurveyAnswersAsync(Request request)
|
||||||
{
|
{
|
||||||
/* var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(surveyAnswers);
|
/* var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(surveyAnswers);
|
||||||
|
@ -70,7 +70,12 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
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();
|
app.UseAuthorization();
|
||||||
|
@ -29,13 +29,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var answers = JsonConvert.DeserializeObject<List<Answer>>(responseString);
|
var answers = JsonConvert.DeserializeObject<List<Answer>>(responseString);
|
||||||
|
|
||||||
if (answers == null || !answers.Any())
|
if (answers == null || !answers.Any())
|
||||||
return null;
|
return new List<Answer>();
|
||||||
else return answers;
|
else return answers;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: AnswerServiceProvider.getAnswersAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: AnswerServiceProvider.getAnswersAsync()");
|
||||||
return null;
|
return new List<Answer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,19 +45,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
httpClient.BaseAddress = new Uri(urlBase);
|
httpClient.BaseAddress = new Uri(urlBase);
|
||||||
|
|
||||||
var response = await httpClient.GetAsync("/api/AnswersByResponse/" + responseId);
|
var response = await httpClient.GetAsync("/AnswersByResponse/" + responseId);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
var answers = JsonConvert.DeserializeObject<List<Answer>>(responseString);
|
var answers = JsonConvert.DeserializeObject<List<Answer>>(responseString);
|
||||||
|
|
||||||
if (answers == null || !answers.Any())
|
if (answers == null || !answers.Any())
|
||||||
return null;
|
return new List<Answer>();
|
||||||
else return answers;
|
else return answers;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: AnswerServiceProvider.GetAnswersByResponseId()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: AnswerServiceProvider.GetAnswersByResponseId()");
|
||||||
return null;
|
return new List<Answer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
public class AttachmentServiceProvider : ServiceProviderBase, IAttachmentServiceProvider
|
public class AttachmentServiceProvider : ServiceProviderBase, IAttachmentServiceProvider
|
||||||
{
|
{
|
||||||
public AttachmentServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<AttachmentServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Attachments", configuration.GetValue<string>("EndPointSettings:AttachmentUrlBase"))
|
public AttachmentServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<AttachmentServiceProvider> logger) : base(configuration, httpClient, logger, "/Attachments", configuration.GetValue<string>("EndPointSettings:AttachmentUrlBase"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,13 +27,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var attachments = JsonConvert.DeserializeObject<List<Attachment>>(responseString);
|
var attachments = JsonConvert.DeserializeObject<List<Attachment>>(responseString);
|
||||||
|
|
||||||
if (attachments == null || !attachments.Any())
|
if (attachments == null || !attachments.Any())
|
||||||
return null;
|
return new List<Attachment>();
|
||||||
else return attachments;
|
else return attachments;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: AttachmentServiceProvider.getAttachmentsAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: AttachmentServiceProvider.getAttachmentsAsync()");
|
||||||
return null;
|
return new List<Attachment>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
public class EmployeeServiceProvider :ServiceProviderBase, IEmployeeServiceProvider
|
public class EmployeeServiceProvider :ServiceProviderBase, IEmployeeServiceProvider
|
||||||
{
|
{
|
||||||
public EmployeeServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Employees", configuration.GetValue<string>("EndPointSettings:EmployeeUrlBase"))
|
public EmployeeServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpClient, logger, "/Employees", configuration.GetValue<string>("EndPointSettings:EmployeeUrlBase"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,13 +23,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var employees = JsonConvert.DeserializeObject<List<Employee>>(responseString);
|
var employees = JsonConvert.DeserializeObject<List<Employee>>(responseString);
|
||||||
|
|
||||||
if (employees == null || !employees.Any())
|
if (employees == null || !employees.Any())
|
||||||
return null;
|
return new List<Employee>();
|
||||||
else return employees;
|
else return employees;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: EmployeeServiceProvider.getEmployeesAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: EmployeeServiceProvider.getEmployeesAsync()");
|
||||||
return null;
|
return new List<Employee>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
httpClient.BaseAddress = new Uri(urlBase);
|
httpClient.BaseAddress = new Uri(urlBase);
|
||||||
//ressource = ressource + "/" + employeeID;
|
//ressource = ressource + "/" + employeeID;
|
||||||
var response = await httpClient.GetAsync("/api/Employees/"+ employeeID);
|
var response = await httpClient.GetAsync("/Employees/"+ employeeID);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
var employee = JsonConvert.DeserializeObject<Employee>(responseString);
|
var employee = JsonConvert.DeserializeObject<Employee>(responseString);
|
||||||
|
@ -7,7 +7,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider
|
public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider
|
||||||
{
|
{
|
||||||
public LocationServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<LocationServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Locations", configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
|
public LocationServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<LocationServiceProvider> logger) : base(configuration, httpClient, logger, "/Locations", configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var locations = JsonConvert.DeserializeObject<List<Location>>(responseString);
|
var locations = JsonConvert.DeserializeObject<List<Location>>(responseString);
|
||||||
|
|
||||||
if (locations == null || !locations.Any())
|
if (locations == null || !locations.Any())
|
||||||
return null;
|
return new List<Location>();
|
||||||
else return locations;
|
else return locations;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: LocationServiceProvider.getLocationsAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: LocationServiceProvider.getLocationsAsync()");
|
||||||
return null;
|
return new List<Location>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
public class QuestionServiceProvider : ServiceProviderBase, IQuestionServiceProvider
|
public class QuestionServiceProvider : ServiceProviderBase, IQuestionServiceProvider
|
||||||
{
|
{
|
||||||
public QuestionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<QuestionServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Questions", configuration.GetValue<string>("EndPointSettings:QuestionUrlBase"))
|
public QuestionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<QuestionServiceProvider> logger) : base(configuration, httpClient, logger, "/Questions", configuration.GetValue<string>("EndPointSettings:QuestionUrlBase"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,13 +24,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var questions = JsonConvert.DeserializeObject<List<Question>>(responseString);
|
var questions = JsonConvert.DeserializeObject<List<Question>>(responseString);
|
||||||
|
|
||||||
if (questions == null || !questions.Any())
|
if (questions == null || !questions.Any())
|
||||||
return null;
|
return new List<Question>();
|
||||||
else return questions;
|
else return questions;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: QuestionServiceProvider.getQuestionsAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: QuestionServiceProvider.getQuestionsAsync()");
|
||||||
return null;
|
return new List<Question>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,19 +39,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
httpClient.BaseAddress = new Uri(urlBase);
|
httpClient.BaseAddress = new Uri(urlBase);
|
||||||
var response = await httpClient.GetAsync("/api/GetSurveyQuestions/" + surveyId);
|
var response = await httpClient.GetAsync("/GetSurveyQuestions/" + surveyId);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
var questions = JsonConvert.DeserializeObject<List<SurveyQuestions>>(responseString);
|
var questions = JsonConvert.DeserializeObject<List<SurveyQuestions>>(responseString);
|
||||||
|
|
||||||
if (questions == null || !questions.Any())
|
if (questions == null || !questions.Any())
|
||||||
return null;
|
return new List<SurveyQuestions>();
|
||||||
else return questions;
|
else return questions;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: QuestionServiceProvider.getSurveyQuestionsAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: QuestionServiceProvider.getSurveyQuestionsAsync()");
|
||||||
return null;
|
return new List<SurveyQuestions>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
public class RegionServiceProvider : ServiceProviderBase, IRegionServiceProvider
|
public class RegionServiceProvider : ServiceProviderBase, IRegionServiceProvider
|
||||||
{
|
{
|
||||||
public RegionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<RegionServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Regions", configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
|
public RegionServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<RegionServiceProvider> logger) : base(configuration, httpClient, logger, "/Regions", configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public async Task<List<Region>> getRegionsAsync()
|
public async Task<List<Region>> getRegionsAsync()
|
||||||
@ -21,13 +21,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var regions = JsonConvert.DeserializeObject<List<Region>>(responseString);
|
var regions = JsonConvert.DeserializeObject<List<Region>>(responseString);
|
||||||
|
|
||||||
if (regions == null || !regions.Any())
|
if (regions == null || !regions.Any())
|
||||||
return null;
|
return new List<Region>();
|
||||||
else return regions;
|
else return regions;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: RegionServiceProvider.getRegionsAsync()");
|
logger?.LogError($"Exception Found : {ex.Message} - Ref: RegionServiceProvider.getRegionsAsync()");
|
||||||
return null;
|
return new List<Region>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
this.surveyServiceProvider = surveyServiceProvider;
|
this.surveyServiceProvider = surveyServiceProvider;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
|
|
||||||
seedData();
|
//seedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seedData()
|
private void seedData()
|
||||||
|
@ -8,7 +8,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider
|
public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider
|
||||||
{
|
{
|
||||||
public SurveyServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Surveys", configuration.GetValue<string>("EndPointSettings:SurveyUrlBase"))
|
public SurveyServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpClient, logger, "/Surveys", configuration.GetValue<string>("EndPointSettings:SurveyUrlBase"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// GET request for retrieving surveys
|
/// GET request for retrieving surveys
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// 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).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Route("Surveys")]
|
[Route("Surveys")]
|
||||||
[Route("{Language}/Surveys")]
|
[Route("{language}/Surveys")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetSurveysAsync(string? Language)
|
public async Task<ActionResult> GetSurveysAsync(string? language)
|
||||||
{
|
{
|
||||||
var result = await this.surveyProvider.GetSurveysAsync(Language);
|
var result = await this.surveyProvider.GetSurveysAsync(language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Surveys);
|
return Ok(result.Surveys);
|
||||||
@ -37,11 +37,11 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// GET request for retrieving surveys by ID.
|
/// GET request for retrieving surveys by ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("Surveys/{Id}")]
|
[Route("Surveys/{Id}")]
|
||||||
[Route("{Language}/Surveys/{Id}")]
|
[Route("{language}/Surveys/{Id}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetSurveysAsync(int Id, string? Language)
|
public async Task<ActionResult> GetSurveysAsync(int Id, string? language)
|
||||||
{
|
{
|
||||||
var result = await this.surveyProvider.GetSurveysAsync(Id, Language);
|
var result = await this.surveyProvider.GetSurveysAsync(Id, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Surveys);
|
return Ok(result.Surveys);
|
||||||
|
@ -53,7 +53,12 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
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();
|
app.UseAuthentication();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user