Merged PR 112: Group by issue in responses

Group by issue in responses
This commit is contained in:
Uppu, Vijay 2024-01-22 21:16:45 +00:00
commit 947ee16281

View File

@ -82,7 +82,7 @@ namespace DamageAssesment.Api.Responses.Providers
}
listSurveyResponse = listSurveyResponse
.OrderByDescending(obj => obj.Id)
.GroupBy(obj => new { obj.SurveyId, obj.EmployeeId, obj.LocationId })
.GroupBy(obj => new { obj.SurveyId, obj.LocationId })//obj.EmployeeId,
.Select(group => group.FirstOrDefault()) // or .FirstOrDefault() if you want to handle empty groups
.ToList();
if (listSurveyResponse.Any())
@ -583,7 +583,7 @@ namespace DamageAssesment.Api.Responses.Providers
}
surveyResonses = surveyResonses
.OrderByDescending(obj => obj.Id)
.GroupBy(obj => new { obj.SurveyId, obj.EmployeeId, obj.LocationId })
.GroupBy(obj => new { obj.SurveyId, obj.LocationId })//obj.EmployeeId,
.Select(group => group.FirstOrDefault()) // or .FirstOrDefault() if you want to handle empty groups
.ToList();
@ -921,7 +921,7 @@ namespace DamageAssesment.Api.Responses.Providers
}
surveyResonses = surveyResonses
.OrderByDescending(obj => obj.Id)
.GroupBy(obj => new { obj.SurveyId, obj.EmployeeId, obj.LocationId })
.GroupBy(obj => new { obj.SurveyId, obj.LocationId }) //obj.EmployeeId,
.Select(group => group.FirstOrDefault()) // or .FirstOrDefault() if you want to handle empty groups
.ToList();
var answers = await answerServiceProvider.getAnswersAsync(token);
@ -991,7 +991,7 @@ namespace DamageAssesment.Api.Responses.Providers
}
surveyResponses = surveyResponses
.OrderByDescending(obj => obj.Id)
.GroupBy(obj => new { obj.SurveyId, obj.EmployeeId, obj.LocationId })
.GroupBy(obj => new { obj.SurveyId, obj.LocationId })//, obj.EmployeeId
.Select(group => group.FirstOrDefault()) // or .FirstOrDefault() if you want to handle empty groups
.ToList();
//var surveyResponses = await surveyResponseDbContext.Responses.Where(x => x.SurveyId == survey.Id).ToListAsync();