コード例 #1
0
        public async Task <IActionResult> Fill(AllQuestionsViewModel input)
        {
            foreach (var question in input.Questions)
            {
                await this.surveyService.AddOpinionToQuestionAsync(question.Question, question.Answer);
            }

            await this.surveyService.AddSurveyToUser(this.userManager.GetUserId(this.User), input.Topic);

            return(this.Redirect("/Surveys/All"));
        }
コード例 #2
0
        public async Task <IActionResult> All(string id)
        {
            var allQuestionsVM = new AllQuestionsViewModel
            {
                AllQuestions = await _context.Question.Where(p => p.User.NickName == id).ToListAsync(),
                User         = await _context.Users.SingleOrDefaultAsync(p => p.NickName == id),
            };

            ViewData["UserProvided"] = id;

            return(View(allQuestionsVM));
        }
        public IActionResult All()
        {
            var questions = this.service.GetMostPopularQuestions <QuestionViewModel>();

            foreach (var question in questions)
            {
                if (question.Text.Length > 50)
                {
                    question.Text = question.Text.Substring(0, 50) + "...";
                }
            }

            var model = new AllQuestionsViewModel {
                Questions = questions
            };

            return(this.View(model));
        }
コード例 #4
0
        public IActionResult Fill(string topic)
        {
            var questions = new List <QuestionViewModel>();

            foreach (var question in this.surveyService.GetAllQuestions(topic))
            {
                questions.Add(new QuestionViewModel {
                    Question = question, Answer = string.Empty
                });
            }

            var model = new AllQuestionsViewModel {
                Questions = questions, Topic = topic
            };

            this.TempData["topic"] = topic;
            return(this.View(model));
        }