Example #1
0
        public async Task <IActionResult> GetById(
            [HttpTrigger(AuthorizationLevel.Anonymous, HttpVerbs.GET, Route = "Community/{id}")] HttpRequest req,
            string id,
            ILogger log)
        {
            var result = await communityService.GetById(id);

            return(new OkObjectResult(result));
        }
Example #2
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 #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"));
            }
        }