Ejemplo n.º 1
0
        public IActionResult AddAnswer(Answer answer)
        {
            var repository = new QuestionsRepository(_conn);

            repository.AddAnswer(answer);
            return(Redirect($"/home/questionpage?id={answer.Id}"));
        }
Ejemplo n.º 2
0
        public IActionResult AddAnswer(Answer answer)
        {
            var repo = new QuestionsRepository(_connectionString);

            repo.AddAnswer(answer);
            return(Redirect($"/home/viewQuestion?questionId={answer.QuestionId}"));
        }
Ejemplo n.º 3
0
        public IActionResult AddAnswer(Answer answer)
        {
            var repo = new QuestionsRepository(_connectionString);

            answer.DateAnswered = DateTime.Now;
            answer.UserId       = GetCurrentUserId().Value;
            repo.AddAnswer(answer);
            return(this.RedirectToAction
                       ("ViewQuestion", new { id = $"{answer.QuestionId}" }));
        }
Ejemplo n.º 4
0
        public IActionResult AddAnswer(Answer answer)
        {
            var repo = new QuestionsRepository(_connectionString);

            answer.DateAnswered = DateTime.Now;
            var email = User.Identity.Name;

            answer.UserId = repo.GetByEmail(email).Id;
            repo.AddAnswer(answer);
            return(Redirect($"/home/ViewQuestion?id={answer.QuestionId}"));
        }
Ejemplo n.º 5
0
        public IActionResult AddAnswer(Answer answer)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("/"));
            }

            var usersRepo    = new UsersRepository(_connectionString);
            var questionRepo = new QuestionsRepository(_connectionString);

            answer.Date   = DateTime.Now;
            answer.UserId = usersRepo.GetUserByEmail(User.Identity.Name).ID;
            questionRepo.AddAnswer(answer);
            return(Redirect($"/question/viewquestion?id={answer.QuestionId}"));
        }
Ejemplo n.º 6
0
        public IActionResult AddAnswer(int questionId, string text)
        {
            var userRepo = new UserRepository(_connectionString);
            var user     = userRepo.GetByEmail(User.Identity.Name);
            var answer   = new Answer
            {
                Date       = DateTime.Now,
                Text       = text,
                QuestionId = questionId,
                UserId     = user.Id
            };
            var questionRepo = new QuestionsRepository(_connectionString);

            questionRepo.AddAnswer(answer);
            return(RedirectToAction("ViewQuestion", new { id = questionId }));
        }