Merge branch 'docker-sql' of https://dev.azure.com/MDCSB-Telecommuters/Emergency%20Preparedness%20Disaster%20Recovery%20Project%20%28EPDRP%29/_git/Backend-API-Services into docker-sql
This commit is contained in:
commit
8624eeeb97
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,6 +5,7 @@
|
|||||||
public int CategoryId { get; set; }
|
public int CategoryId { get; set; }
|
||||||
public string IconName { get; set; }
|
public string IconName { get; set; }
|
||||||
public string IconLibrary { get; set; }
|
public string IconLibrary { get; set; }
|
||||||
|
public object CategoryNames { get; set; }
|
||||||
public List<MultiLanguage> QuestionsText { get; set; }
|
public List<MultiLanguage> QuestionsText { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,6 +313,7 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
CategoryId = item.Id,
|
CategoryId = item.Id,
|
||||||
IconLibrary = item.IconLibrary,
|
IconLibrary = item.IconLibrary,
|
||||||
IconName = item.IconName,
|
IconName = item.IconName,
|
||||||
|
CategoryNames= CreateCategoryMultiLanguageObject(GetCategoryTranslations(item.Id, language)),
|
||||||
QuestionsText = GetSurveyQuestion(mapper.Map<List<Db.Question>, List<Models.MultiLanguage>>(questions.Where(a => a.CategoryId == item.Id).ToList()), language)
|
QuestionsText = GetSurveyQuestion(mapper.Map<List<Db.Question>, List<Models.MultiLanguage>>(questions.Where(a => a.CategoryId == item.Id).ToList()), language)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -199,10 +199,12 @@ namespace DamageAssesment.Api.Responses.Controllers
|
|||||||
return BadRequest(result.ErrorMessage);
|
return BadRequest(result.ErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("responses/surveys/active")]
|
||||||
|
[Route("responses/surveys/active/{language:alpha}")]
|
||||||
[Route("responses/surveys/active/{employeeid:int}")]
|
[Route("responses/surveys/active/{employeeid:int}")]
|
||||||
[Route("responses/surveys/active/{employeeid:int}/{language:alpha}")]
|
[Route("responses/surveys/active/{employeeid:int}/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetActiveSurveysAsync(int employeeid, string? language)
|
public async Task<ActionResult> GetActiveSurveysAsync(int? employeeid, string? language)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetActiveSurveysAsync(employeeid, language);
|
var result = await this.surveyResponseProvider.GetActiveSurveysAsync(employeeid, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
@ -212,10 +214,12 @@ namespace DamageAssesment.Api.Responses.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("responses/surveys/historic")]
|
||||||
|
[Route("responses/surveys/historic/{language:alpha}")]
|
||||||
[Route("responses/surveys/historic/{employeeid:int}")]
|
[Route("responses/surveys/historic/{employeeid:int}")]
|
||||||
[Route("responses/surveys/historic/{employeeid:int}/{language:alpha}")]
|
[Route("responses/surveys/historic/{employeeid:int}/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetHistoricSurveysAsync(int employeeid, string? language)
|
public async Task<ActionResult> GetHistoricSurveysAsync(int? employeeid, string? language)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetHistoricSurveysAsync(employeeid, language);
|
var result = await this.surveyResponseProvider.GetHistoricSurveysAsync(employeeid, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
|
@ -9,8 +9,8 @@ namespace DamageAssesment.Api.Responses.Interfaces
|
|||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyResponseAsync(Models.SurveyResponse surveyResponse);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyResponseAsync(Models.SurveyResponse surveyResponse);
|
||||||
// Task<(bool IsSuccess,dynamic surveyResponses, string ErrorMessage)> GetSurveyResponseAsync(int responseId);
|
// Task<(bool IsSuccess,dynamic surveyResponses, string ErrorMessage)> GetSurveyResponseAsync(int responseId);
|
||||||
Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync(int employeeid);
|
Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync(int employeeid);
|
||||||
Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetActiveSurveysAsync(int employeeid, string language);
|
Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetActiveSurveysAsync(int? employeeid, string language);
|
||||||
Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetHistoricSurveysAsync(int employeeid, string language);
|
Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetHistoricSurveysAsync(int? employeeid, string language);
|
||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse);
|
||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> DeleteSurveyResponseAsync(int Id);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> DeleteSurveyResponseAsync(int Id);
|
||||||
Task<(bool IsSuccess, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId);
|
Task<(bool IsSuccess, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId);
|
||||||
|
@ -112,24 +112,18 @@ namespace DamageAssesment.Api.Responses.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetActiveSurveysAsync(int employeeid, string language)
|
public async Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetActiveSurveysAsync(int? employeeid, string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
||||||
//get all the survey that already taken by the employee
|
//get all the survey that already taken by the employee
|
||||||
var listOfsurveysId = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).Select(y => y.SurveyId).ToListAsync();
|
|
||||||
var surveys = await surveyServiceProvider.getSurveysAsync(language);
|
var surveys = await surveyServiceProvider.getSurveysAsync(language);
|
||||||
|
|
||||||
if (surveys != null)
|
|
||||||
{
|
|
||||||
surveys = surveys.Where(s => s.IsEnabled == true && s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now).ToList();
|
surveys = surveys.Where(s => s.IsEnabled == true && s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now).ToList();
|
||||||
}
|
if (employeeid == null || employeeid == 0)
|
||||||
|
|
||||||
if (listOfsurveysId==null || listOfsurveysId.Count == 0)
|
|
||||||
return (true, surveys, null);
|
return (true, surveys, null);
|
||||||
|
List<int> listOfsurveysId = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid.Value).Select(y => y.SurveyId).ToListAsync();
|
||||||
var activeSurveys = surveys.Where(s => s.IsEnabled == true && s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now && !listOfsurveysId.Contains(s.Id));
|
var activeSurveys = surveys.Where(s => !listOfsurveysId.Contains(s.Id));
|
||||||
return (true, activeSurveys, null);
|
return (true, activeSurveys, null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -139,21 +133,24 @@ namespace DamageAssesment.Api.Responses.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetHistoricSurveysAsync(int employeeid, string language)
|
public async Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetHistoricSurveysAsync(int? employeeid, string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
||||||
//get all the survey that already taken by the employee
|
|
||||||
var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).ToListAsync();
|
|
||||||
var surveys = await surveyServiceProvider.getSurveysAsync(language);
|
|
||||||
|
|
||||||
|
var surveys = await surveyServiceProvider.getSurveysAsync(language);
|
||||||
|
// returning only historic data: end date is less than current date.
|
||||||
|
surveys = surveys.Where(s => s.EndDate < DateTime.Now).ToList();
|
||||||
|
if (employeeid == null || employeeid == 0)
|
||||||
|
return (true, surveys, null);
|
||||||
|
var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).ToListAsync();
|
||||||
var historicSurveys = from s in surveys
|
var historicSurveys = from s in surveys
|
||||||
from r in surveyResponses
|
from r in surveyResponses
|
||||||
where s.Id == r.SurveyId
|
where s.Id == r.SurveyId
|
||||||
select s;
|
select s;
|
||||||
|
|
||||||
return (true, historicSurveys, null);
|
return (true, historicSurveys, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,8 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Get all Surveys from DB");
|
logger?.LogInformation("Get all Surveys from DB");
|
||||||
var surveys = await surveyDbContext.Surveys.Where(s => s.IsEnabled == true).ToListAsync();
|
//checking is enabled in survey response
|
||||||
|
var surveys = await surveyDbContext.Surveys.ToListAsync();//Where(s => s.IsEnabled == true)
|
||||||
|
|
||||||
if (surveys != null)
|
if (surveys != null)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user