public IActionResult ViewQuestion(int questionId) { if (questionId <= 0) { return(RedirectToAction("Index")); } var repo = new QTRepository(_connectionString); Question question = repo.GetQuestionById(questionId); if (question == null) { return(RedirectToAction("Index")); } var vm = new ViewQuestionViewModel { Question = question, IsAuthenticated = User.Identity.IsAuthenticated }; if (vm.IsAuthenticated == true) { vm.User = repo.GetUserByEmail(User.Identity.Name); } return(View(vm)); }
public IActionResult NewQuestion(Question question, string tags) { List <string> tagList = new List <string>(); tagList = tags.Split(' ').ToList(); var repo = new QTRepository(_connectionString); question.DatePosted = DateTime.Now; question.UserId = repo.GetUserByEmail(User.Identity.Name).Id; repo.AddQuestion(question, tagList); return(Redirect("/")); }