示例#1
0
 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());;
 }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        public async Task AddCommentAsync(SurveyComment surveyComment)
        {
            await _context.SurvaysComments.AddAsync(surveyComment);

            await _context.SaveChangesAsync();
        }