public ActionResult MarkAsAnswer(Post post, ReturnUrl url)
        {
            var question = _repositories.Questions.Get().WithId(post.QuestionId);

            if (!_security.CanMarkAsAnswer(question, UserModel.Current.UserName))
            {
                TempData["message"] = _security.ErrorMessage;
                return RedirectToAction("Details", new { id = question.Id });
            }

            question.MarkAsAnswer(post.Id, UserModel.Current.UserName);
            _repositories.Questions.SaveChanges();

            TempData["message"] = "You have successfully marked this question as answered. The question is now closed.";

            return RedirectToAction("Details", new {id = question.Id});
        }
        public ActionResult Reply(Post reply, int id, ReturnUrl url)
        {
            var question = _repositories.Questions.Get().WithId(id);

            if (question == null) return View("NotFound");

            if (!_security.HasReplyAccess(question, UserModel.Current.UserName))
            {
                TempData["message"] = _security.ErrorMessage;
                return RedirectToAction("Details", new { id = id, r = url.Url });
            }

            if (this.ModelState.IsValid)
            {
                try
                {
                    reply.CreatedBy = UserModel.Current.UserName;
                    reply.CreatedDate = DateTime.Now;

                    question.AddReply(reply);

                    _repositories.Questions.SaveChanges();

                    var user = Membership.GetUser(question.CreatedBy);
                    if (user != null)
                        _emailService.SendEmailTo(user.Email,
                                                  new StandardEmail(StandardEmail.EmailTemplate.LawyerReply));

                    return RedirectToAction("Details", new { id, r = url.Url });
                }
                catch (Exception e)
                {
                    this.ModelState.AddModelError("*", e.ToString());
                }
            }

            return View(new ReplyViewModel(question));
        }
        public ActionResult MarkAsAnswer(int questionId, int postId, ReturnUrl url)
        {
            var question = _repositories.Questions.Get().WithId(questionId);

            if(!_security.CanMarkAsAnswer(question, UserModel.Current.UserName))
            {
                TempData["message"] = _security.ErrorMessage;
                return RedirectToAction("Details", new { id = questionId });
            }

            var post = question.Responses.WithId(postId);

            return View(post);
        }