public int QuestionStats(int idquest, SurveyComment comment) { /* int nbrq = GetMany(q => q.surveyQuestId == idquest && q.comment == comment).Count(); * int nbrt = GetMany(q => q.surveyQuestId == idquest).Count(); * if (nbrq == 0 || nbrt == 0) * return 0; * * double result = 1 / ( nbrt / nbrq ) *100d;*/ return(GetMany(q => q.surveyQuestId == idquest && q.comment == comment).Count());; }
private void BuildSurvey(Data.Survey survey, Question question) { if (!string.IsNullOrWhiteSpace(Request.Form[question.Id.ToString()])) { switch (question.Type) { case 0: case 1: var ans = new SurveyAnswer() { AnswerId = Convert.ToInt32(Request.Form[question.Id.ToString()]) }; survey.SurveyAnswers.Add(ans); break; case 2: string[] values = Request.Form[question.Id.ToString()].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var val in values) { var a = new SurveyAnswer() { AnswerId = Convert.ToInt32(val) }; survey.SurveyAnswers.Add(a); } break; case 3: var comment = new SurveyComment() { QuestionId = question.Id, Comments = Request.Form[question.Id.ToString()] }; survey.SurveyComments.Add(comment); break; } } }
public async Task AddCommentAsync(SurveyComment surveyComment) { await _context.SurvaysComments.AddAsync(surveyComment); await _context.SaveChangesAsync(); }