public IActionResult NewAnswer([FromForm(Name = "answer")] string answer, [FromForm(Name = "qID")] string qID, [FromForm(Name = "image")] string image, [FromForm(Name = "currentUser")] string currentUser) { if (image == null || !image.StartsWith("https://")) { image = "https://"; } ds.AddAnswer(ds.MakeAnswerWoId(qID, currentUser, answer, image)); //foreach (Question question in ds.GetQuestions()) //{ // ViewData.Add(question.Id.ToString(), question.Title); //} return(RedirectToAction("ShowQe", "Questions", new { qid = QuestionsController.focusQid }));; }
public IActionResult Answers(QuestionAnswersViewModel qm) { if (!ModelState.IsValid) { return(DisplayQuestionAndAnswersView(qm.Question.Id)); } User user = _dataService.GetUser(this.User.Identity.Name); Answer answer = new Answer { QuestionId = qm.Question.Id, UserId = user.Id, DateCreated = DateTime.Now, Text = qm.Answer }; _dataService.AddAnswer(answer); return(RedirectToAction("Answers", new { id = qm.Question.Id })); }