Пример #1
0
        public ActionResult Edit(AnswerEditModel model)
        {
            if (this.ModelState.IsValid)
            {
                var userId = this.User.Identity.GetUserId();
                var answer = this.Data.Answers.GetById(model.Id);

                answer.Content = model.Content;

                this.Data.Answers.Update(answer);
                this.Data.SaveChanges();

                if (model.Reason != null)
                {
                    var answerUpdate = new AnswerUpdate
                    {
                        AuthorId = userId,
                        AnswerId = answer.Id,
                        Reason   = model.Reason
                    };

                    this.Data.AnswerUpdates.Add(answerUpdate);
                    this.Data.SaveChanges();
                }

                var viewModel = Mapper.Map <AnswerViewModel>(answer);
                viewModel.IsUpdating = true;

                return(this.PartialView("_AnswerDetailPartial", viewModel));
            }

            return(this.JsonError("Content is required"));
        }
Пример #2
0
        public ActionResult UpdateAnswer([FromBody] AnswerUpdate req)
        {
            IdeationAnswers answer = _context.IdeationAnswers.First(a => a.Uid == req.Uid);

            answer.Answer = req.Answer;

            _context.SaveChanges();

            return(Ok(new { message = "Success!" }));
        }