fixed region issue
This commit is contained in:
parent
1b638d9367
commit
5644762e00
@ -71,16 +71,20 @@ namespace DamageAssesment.Api.Responses.Providers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
||||||
IQueryable<Db.SurveyResponse> listSurveyResponse = null;
|
List<Db.SurveyResponse> listSurveyResponse = null;
|
||||||
if (employeeid == 0)
|
if (employeeid == 0)
|
||||||
{
|
{
|
||||||
listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId);
|
listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId && s.EmployeeId == employeeid);
|
listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId && s.EmployeeId == employeeid).ToList();
|
||||||
}
|
}
|
||||||
|
listSurveyResponse = listSurveyResponse
|
||||||
|
.OrderByDescending(obj => obj.Id)
|
||||||
|
.GroupBy(obj => new { obj.SurveyId, obj.EmployeeId, obj.LocationId })
|
||||||
|
.Select(group => group.FirstOrDefault()) // or .FirstOrDefault() if you want to handle empty groups
|
||||||
|
.ToList();
|
||||||
if (listSurveyResponse.Any())
|
if (listSurveyResponse.Any())
|
||||||
{
|
{
|
||||||
var answers = await getAnswersByRegionAndSurveyIdAsync(listSurveyResponse);
|
var answers = await getAnswersByRegionAndSurveyIdAsync(listSurveyResponse);
|
||||||
@ -432,7 +436,7 @@ namespace DamageAssesment.Api.Responses.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method to get Answers by region with surveyId as input parameter
|
//Method to get Answers by region with surveyId as input parameter
|
||||||
private async Task<dynamic> getAnswersByRegionAndSurveyIdAsync(IQueryable<Db.SurveyResponse> surveyResponses)
|
private async Task<dynamic> getAnswersByRegionAndSurveyIdAsync(List<Db.SurveyResponse> surveyResponses)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user