public IActionResult Details(int id) { var community = _communityService.GetById(id); var posts = _postService.GetAll(item => item.CommunityId == id).ToList(); var model = new CommunityDetailsViewModel(); model.Posts = Helper.ConvertToHomePostIndexViewModel(posts, _commentService); model.Community = community; return(View(model)); }
public ActionResult Details(int communityId) { // Querying the database for each property can get expensive. CommunityDetailsViewModel viewModel = new CommunityDetailsViewModel { Community = CommunityShedData.GetCommunity(communityId), PersonRoles = CommunityShedData.GetCommunityPersonRoles(communityId), Members = CommunityShedData.GetCommunityMembers(communityId), CanEdit = CustomUser.CanEditCommunity(communityId), CanEditMembers = CustomUser.IsInRole("Enforcer", communityId) }; return(View(viewModel)); }
public IActionResult Details(int id) { try { var community = _communityService.GetById(id); var posts = _postService.GetAll(item => item.CommunityId == id).OrderByDescending(a => a.CreatedAt).ToList(); var model = new CommunityDetailsViewModel(); model.Posts = posts.ConvertToHomePostIndexViewModel(_commentService); model.Community = community; return(View(model)); } catch (Exception ex) { var msg = ex.Message; return(RedirectToAction("Error", "Home")); } }