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;
            }
        }
Beispiel #2
0
        // GET: PostTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PostType postType = PostTypesOps.GetPostTypeById(id.Value);

            if (postType == null)
            {
                return(HttpNotFound());
            }

            return(View(postType));
        }