Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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"));
            }
        }