public async Task <string> GetAnswerForQuestionAsync(string userId, string question) { BuildupForm form = await GetFormAsync(userId); if (form == null) { return(null); } BuildupFormQA formQA = await(await _formsQAs.FindAsync(databaseFormQA => databaseFormQA.FormId == form.Id && databaseFormQA.Question == question )).FirstOrDefaultAsync(); return(formQA?.Answer); }
public async Task RegisterFormToDatabseAsync(string userId, List <BuildupFormQA> qas) { BuildupForm newForm = new BuildupForm() { UserId = userId }; await _forms.InsertOneAsync(newForm); for (int i = 0; i < qas.Count; ++i) { qas[i].FormId = newForm.Id; qas[i].Index = i; } await _formsQAs.InsertManyAsync(qas); }
public async Task <List <BuildupFormQA> > GetFormQAsAsync(string userId) { BuildupForm form = await GetFormAsync(userId); if (form == null) { return(null); } List <BuildupFormQA> formQAs = await(await _formsQAs.FindAsync(databaseQA => databaseQA.FormId == form.Id, new FindOptions <BuildupFormQA>() { Sort = Builders <BuildupFormQA> .Sort.Ascending("index") } )).ToListAsync(); return(formQAs); }