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)); }
public ActionResult Edit(Guid Id) { using (UnitOfWorkManager.NewUnitOfWork()) { var cats = _categoryService.GetAllowedEditCategories(UsersRole); if (cats.Count > 0) { var viewModel = new CreateEditTopicViewModel(); 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; 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"))); } }