public ActionResult CreateAnswer(int postId)
        {
            var inputModel = new InputAnswerViewModel
            {
                PostId = postId
            };

            return this.PartialView("_CreateAnswerPartial", inputModel);
        }
        public ActionResult CreateAnswer(int postId)
        {
            var inputModel = new InputAnswerViewModel
            {
                PostId = postId
            };

            return(PartialView("_CreateAnswerPartial", inputModel));
        }
Exemplo n.º 3
0
        public ActionResult InputAnswer(int id)
        {
            var question = new InputAnswerViewModel()
            {
                QuestionId = id
            };

            return(PartialView("InputAnswer", question));
        }
Exemplo n.º 4
0
        public ActionResult InputAnswer(InputAnswerViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userId = this.GetUserId();
                var answer = new Answer
                {
                    Body       = model.Body,
                    AuthorId   = userId,
                    QuestionId = model.Id,
                    AnsweredOn = DateTime.Now
                };

                this.Data.Answers.Add(answer);
                this.Data.SaveChanges();
                return(this.RedirectToAction("Details", new { id = model.Id }));
            }
            return(this.View(model));
        }
        public ActionResult CreateAnswer(InputAnswerViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                this.TempData["NotificationError"] = "Sorry but something wrong. Please try angain later and don't forget content on answer";
                return this.Redirect(this.Request.UrlReferrer.ToString());
            }

            var userId = this.User.Identity.GetUserId();

            var answer = new Answer
            {
                Content = model.Content,
                UserId = userId,
                PostId = model.PostId
            };

            this.answers.CreateAnswer(answer);

            this.TempData["Notification"] = "You successfully answer on post.";

            return this.Redirect(this.Request.UrlReferrer.ToString());
        }
        public ActionResult CreateAnswer(InputAnswerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                TempData["NotificationError"] = "Sorry but something wrong. Please try angain later and don't forget content on answer";
                return(Redirect(Request.UrlReferrer.ToString()));
            }

            var userId = User.Identity.GetUserId();

            var answer = new Answer
            {
                Content = model.Content,
                UserId  = userId,
                PostId  = model.PostId
            };

            m_Answers.CreateAnswer(answer);

            TempData["Notification"] = "You successfully answer on post.";

            return(Redirect(Request.UrlReferrer.ToString()));
        }