forked from MDCPS/DamageAssessment_Backend
Conflict resolved in Questions, Surveys
This commit is contained in:
@ -709,16 +709,16 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
||||
}
|
||||
|
||||
|
||||
async Task<bool> ProcessAnswers(QuestionRequest questionRequest, int surveyResponseId)
|
||||
bool ProcessAnswers(QuestionRequest questionRequest, int surveyResponseId)
|
||||
{
|
||||
if (questionRequest != null)
|
||||
{
|
||||
var answer = await answerServiceProvider.PostAnswersAsync(new Answer { Id = 0, QuestionId = questionRequest.QuestionId, AnswerText = questionRequest.AnswerText, Comment = questionRequest.Comment, SurveyResponseId = surveyResponseId });
|
||||
var answer = answerServiceProvider.PostAnswersAsync(new Answer {QuestionId = questionRequest.QuestionId, AnswerText = questionRequest.AnswerText, Comment = questionRequest.Comment, SurveyResponseId = surveyResponseId });
|
||||
if (answer != null)
|
||||
{
|
||||
List<AnswerInfo> listAnswerInfo = new List<AnswerInfo>();
|
||||
listAnswerInfo.Add(new AnswerInfo { AnswerId = answer.Id, postedFiles = questionRequest.PostedFiles });
|
||||
var attachments = await attachmentServiceProvider.PostAttachmentsAsync(new AttachmentInfo { ResponseId = surveyResponseId, Answers = listAnswerInfo });
|
||||
var attachments = attachmentServiceProvider.PostAttachmentsAsync(new AttachmentInfo { ResponseId = surveyResponseId, Answers = listAnswerInfo });
|
||||
|
||||
string message = $"Answer for question {questionRequest.QuestionId} saved to the database";
|
||||
logger?.LogInformation(message);
|
||||
@ -757,18 +757,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
||||
//var tasks = answers.Answers.Select(x => ProcessAnswers(x,surveyResponse.SurveyResponseID));
|
||||
foreach (QuestionRequest ans in answers.Answers)
|
||||
{
|
||||
ProcessAnswers(ans, surveyResponse.Id);
|
||||
//var stopwatch = new Stopwatch();
|
||||
//stopwatch.Start();
|
||||
var task = Task.Run(() => ProcessAnswers(ans, surveyResponse.Id));
|
||||
// var task = Task.Run(() => ProcessAnswers(ans, surveyResponse.Id));
|
||||
|
||||
//var task = await ProcessAnswers(ans, surveyResponse.Id);
|
||||
answerTasks.Add(task);
|
||||
//answerTasks.Add(task);
|
||||
|
||||
|
||||
//stopwatch.Stop();
|
||||
//answerTasks.Add(ProcessAnswers(ans, surveyResponse.Id));
|
||||
}
|
||||
await Task.WhenAll(answerTasks);
|
||||
//await Task.WhenAll(answerTasks);
|
||||
return (true, surveyResponse, null);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user