コード例 #1
0
        public RedirectToRouteResult RateQuestions(QuestionRate rate)
        {
            var userId = User.Identity.GetUserId();

            _psychologistManager.AddOrUpdateRateQuestion(rate.Grade, userId, rate.Id);
            //userId = User.Identity.GetUserId();
            //_psychologistManager.AddOrUpdateRateQuestion(grade, userId, questionId);
            return(RedirectToAction("RateQuestions"));
        }
コード例 #2
0
        public ActionResult RateQuestions()
        {
            string userId = User.Identity.GetUserId();

            var reatedQuestions    = _psychologistManager.GetPsychologist(userId).QuestionsGrades.ToList();
            var listofAllQuestions = _psychologistManager.GetAllQuestions();
            var model = new RateQuestionViewModel();

            model.QuestionRates = new List <QuestionRate>();
            model.UserId        = userId;
            foreach (Question question in listofAllQuestions)
            {
                QuestionRate singleRate = new QuestionRate();
                singleRate.Id       = question.Id;
                singleRate.Question = question.Content;
                var reatedQuestion = reatedQuestions.SingleOrDefault(x => x.Question.Id == question.Id);
                singleRate.Grade = reatedQuestion?.Value;

                model.QuestionRates.Add(singleRate);
            }

            return(View(model.QuestionRates));
        }