예제 #1
0
        public async Task <JsonResult> GetCommunityContents(long communityId)
        {
            if (CurrentUserId == 0)
            {
                await TryAuthenticateFromHttpContext();
            }
            var contents = await _communityService.GetCommunityContents(communityId, CurrentUserId);

            var entities = new List <EntityViewModel>();

            foreach (var item in contents)
            {
                var contentViewModel = new ContentViewModel();
                contentViewModel.SetValuesFrom(item);
                entities.Add(contentViewModel);
            }
            var children = await _communityService.GetChildCommunities(communityId, CurrentUserId);

            var childCommunities = new List <CommunityViewModel>();

            foreach (var child in children)
            {
                var communityViewModel = new CommunityViewModel();
                Mapper.Map(child, communityViewModel);
                childCommunities.Add(communityViewModel);
            }
            return(Json(new{ entities, childCommunities }, JsonRequestBehavior.AllowGet));
        }