From 65b4ca6356147c0a81ccd7b0cb0ecf6748697f4e Mon Sep 17 00:00:00 2001 From: Vijay Uppu <913468@dadeschools.net> Date: Mon, 22 Jan 2024 12:09:00 -0500 Subject: [PATCH] Group by issue in responses --- .../Providers/SurveyResponsesProvider.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Responses/Providers/SurveyResponsesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Responses/Providers/SurveyResponsesProvider.cs index 211a394..96816f8 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Responses/Providers/SurveyResponsesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Responses/Providers/SurveyResponsesProvider.cs @@ -67,7 +67,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()) @@ -570,7 +570,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(); @@ -954,7 +954,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(); @@ -1029,7 +1029,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();