コード例 #1
0
        public ActionResult Create([Bind(Include = "Id,Title,ShortDescription,PostContent,Meta,UrlSlug,Published,PostedOn,Modified,CategoryId,ViewCount,RateCount,TotalRate")] Post post)
        {
            post.UrlSlug  = UrlUtility.GenerateSlug(post.Title);
            post.PostedOn = DateTime.Now;
            post.Modified = DateTime.Now;
            if (ModelState.IsValid)
            {
                var temp = _postRepository.Add(post);
                return(RedirectToAction("Index"));
            }

            var categoriesList = _categoryRepository.GetAll();

            ViewBag.CategoryId = new SelectList(categoriesList, "Id", "Name");
            return(View(post));
        }