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); }
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); }