Пример #1
0
        // GET: Answers/Details/5
        /// <summary>
        /// Single reusable action for displaying answer
        /// </summary>
        /// <param name="AnswerCount"></param>
        /// <param name="model">The answer to display</param>
        /// <param name="_View">Eg: Details for display, Edit for editing, Delete for deleting </param>
        /// <returns>The view specified by _View</returns>
        public ActionResult Details(int AnswerId, QAModel model, string _View)
        {
            try
            {
                AnswerWS Aws = new AnswerWS();

                if (AnswerId > 0)
                {
                    model.answer = Aws.GetAnswerById(AnswerId, this.GetVisitorIP(Session["VisitorIP"]));
                }
                else if (model.question.QuestionId > 0)
                {
                    model.answer = Aws.GetAnswersForQuestion(model.question.QuestionId);
                }

                return(View(_View, model));
            }
            catch (Exception)
            {
                //TODO: log this exception
            }

            TempData["ErrorPrevention"] = "Maybe the data required to display the answer was incomplete. Do you want to <a href='/Questions/Create'> ask a question </a>?";
            ModelState.AddModelError("", "An error occured while displaying answer");
            return(View("Error"));
        }
Пример #2
0
        public ActionResult Edit(int AnswerId)
        {
            TempData["UrlReferrer"] = this.GetRequestReferrer();

            if (!Request.IsAuthenticated)
            {
                TempData["RedirectMsg"] = "You must be logged in first";

                return(View("~/Views/Account/Login.cshtml"));
            }

            Answer model = new Answer();

            TempData["Title"] = "Improve answer!";
            //TempData["Guideline"] = "Thanks for your contribution";

            AnswerWS AWS = new AnswerWS();

            model = AWS.GetAnswerById(AnswerId, this.GetVisitorIP(Session["VisitorIP"]));


            return(View(model));
        }