コード例 #1
0
ファイル: UserPostController.cs プロジェクト: jagudits/fua
        public ActionResult Answer(UserPostViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.AddNew();
                    // what TODO
                    // should we check successful creation?
                    // should we redirect somewhere?
                }
                catch (Exception)
                {
                    return RedirectToAction("Error", "Home", new { msg = "Exception answering a post..." });
                }

            }
            return View("Details", model);
        }
コード例 #2
0
ファイル: UserPostController.cs プロジェクト: jagudits/fua
        public ActionResult Create(UserPostViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    user userLoggedOn = userRepository.GetByUsername(User.Identity.Name);
                    model.user_id = userLoggedOn.id;
                    model.parent_post_id = 0;
                    model.ranking_points = 0;
                    model.num_views = 0;
                    model.is_accepted_answer = false;
                    model.AddNew();
                    // what TODO
                    // should we check successful creation?
                    // should we redirect somewhere?
                }
                catch (Exception)
                {
                    return RedirectToAction("Error", "Home", new { msg = "Exception adding post..." });
                }

            }
            return View("Details", model);
        }