コード例 #1
0
        public ActionResult Edit(Guid Id)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var cats = _categoryService.GetAllowedEditCategories(UsersRole, false);
                if (cats.Count > 0)
                {
                    var viewModel = new AdminCreateEditTopicViewModel();
                    viewModel.Categories = _categoryService.GetBaseSelectListCategories(cats);

                    var topic = _topicServic.Get(Id);

                    if (topic == null)
                    {
                        TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message     = LocalizationService.GetResourceString("Errors.NoFindTopic"),
                            MessageType = GenericMessages.warning
                        };

                        return(RedirectToAction("Index"));
                    }

                    viewModel.Id       = topic.Id;
                    viewModel.Name     = topic.Name;
                    viewModel.Category = topic.Category_Id;
                    viewModel.IsLocked = topic.IsLocked;
                    viewModel.IsSticky = topic.IsSticky;
                    viewModel.Image    = topic.Image;

                    viewModel.Intro          = topic.Intro;
                    viewModel.SEOKeyword     = topic.SEOKeyword;
                    viewModel.SEODescription = topic.SEODescription;

                    if (topic.Post_Id != null)
                    {
                        var post = _postSevice.Get((Guid)topic.Post_Id);
                        if (post != null)
                        {
                            viewModel.Content = post.PostContent;
                        }
                    }
                    //viewModel.Po = topic.IsLocked;



                    return(View(viewModel));
                }
                return(ErrorToHomePage(LocalizationService.GetResourceString("Errors.NoPermission")));
            }
        }
コード例 #2
0
ファイル: TopicController.cs プロジェクト: kaisermtv/WebMvc2
        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));
        }