Example #1
0
        public ActionResult ShowBySlug(string catSlug, string Slug)
        {
            var cat = _categoryService.GetBySlug(catSlug);

            if (cat == null)
            {
                return(RedirectToAction("index", "Catergory"));
            }

            var topic = _topicServic.GetBySlug(Slug);

            if (topic == null || cat.Id != topic.Category_Id)
            {
                return(RedirectToAction("ShowBySlug", "Category", new { slug = cat.Slug }));
            }

            Post post = new Post();

            if (topic.Post_Id != null)
            {
                post = _postSevice.Get((Guid)topic.Post_Id);
            }

            var model = new TopicViewModel
            {
                Cat   = cat,
                topic = topic,
                post  = post
            };

            return(View(model));
        }