public ActionResult Create( [Bind(Include = "Title,Body,SelectedArea,SelectedLocale,SelectedCategory,SelectedSubcategory")] PostViewModel post) { try { if (ModelState.IsValid) { var postType = PostTypesOps.GetPostTypeById(int.Parse(post.SelectedSubcategory)); var location = LocationOps.GetLocationById(int.Parse(post.SelectedLocale)); UserPost.CreatePost(User.Identity.GetUserId(), post.Title, post.Body, post.SelectedCategory, postType.SubCategory, post.SelectedArea, location.Locale); return(RedirectToAction("Index")); } return(View(post)); } catch (Exception e) { Console.WriteLine(e); throw; } }
// GET: Locations/Edit/5 public ActionResult Edit(int?id) { if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Location location = LocationOps.GetLocationById(id.Value); if (location == null) { return(HttpNotFound()); } return(View(location)); }