public DepartmentQuestionResponseSummary(int departmentId, int questionId, AggregatedCounts aggregatedCounts) { DepartmentId = departmentId; QuestionId = questionId; Average = aggregatedCounts.Average; Max = aggregatedCounts.Max; Min = aggregatedCounts.Min; TotalResponses = aggregatedCounts.TotalResponses; }
private async Task SaveSummary(AggregatedCounts aggregatedResults, int departmentId, int questionId, CancellationToken cancellationToken) { var responseSummary = new DepartmentQuestionResponseSummary(departmentId, questionId, aggregatedResults); if (await _responseSummaryRepository.Exists(questionId, departmentId, cancellationToken)) { _responseSummaryRepository.Update(responseSummary); } else { _responseSummaryRepository.Add(responseSummary); } await _responseSummaryRepository.SaveChanges(cancellationToken); }