示例#1
0
        /// <summary>
        /// Inserts a new answer.
        /// </summary>
        /// <returns>Refresh the page.</returns>
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            AnswerData      answerData     = new AnswerData(_db);
            DataAnswerModel newAnswerModel = new DataAnswerModel
            {
                Answer       = DisplayAnswer.Answer,
                Id           = DisplayAnswer.Id,
                PlayerAnswer = DisplayAnswer.PlayerAnswer,
                Type         = DisplayAnswer.Type,
            };

            await answerData.InsertAnswer(newAnswerModel);

            return(RedirectToPage("./answer"));
        }