示例#1
0
        // GET: Feeds/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FeedViewModel feed = Mapper.Map <FeedViewModel>(feedService.Get(id.Value));

            if (feed == null)
            {
                return(HttpNotFound());
            }
            return(View(feed));
        }
示例#2
0
        /// <summary>
        ///     Gets feed items from the underlying feed repository based on a filter.
        /// </summary>
        /// <param name="filter">a filter by which to retrieve feed items by</param>
        /// <returns>A list of feed items.</returns>
        public IEnumerable <CommunityFeedItemViewModel> Get(CommunityFeedFilter filter)
        {
            var feedItems = new List <Composite <FeedItem, CommunityActivity> >();

            try
            {
                feedItems = _feedService.Get(
                    new CompositeCriteria <FeedItemFilter, CommunityActivity>
                {
                    PageInfo = new PageInfo
                    {
                        PageSize = filter.PageSize
                    },
                    IncludeSubclasses = true,
                    Filter            = new FeedItemFilter
                    {
                        Subscriber = Reference.Create(filter.Subscriber)
                    },
                    OrderBy = { new SortInfo(FeedItemSortFields.ActivityDate, false) }
                }
                    ).Results.ToList();
            }
            catch (SocialAuthenticationException ex)
            {
                throw new SocialRepositoryException("The application failed to authenticate with Episerver Social.",
                                                    ex);
            }
            catch (MaximumDataSizeExceededException ex)
            {
                throw new SocialRepositoryException(
                          "The application request was deemed too large for Episerver Social.", ex);
            }
            catch (SocialCommunicationException ex)
            {
                throw new SocialRepositoryException("The application failed to communicate with Episerver Social.", ex);
            }
            catch (SocialException ex)
            {
                throw new SocialRepositoryException("Episerver Social failed to process the application request.", ex);
            }

            return(AdaptFeedItems(feedItems));
        }
        public async Task <SearchQueryResult <ArticleQueryResult> > Handle(SearchArticlesInFeedQuery request, CancellationToken cancellationToken)
        {
            var feed = await _feedService.Get(request.FeedId, cancellationToken);

            if (feed.UserId != request.UserId)
            {
                _logger.LogError($"the user {request.UserId} doesn't have the right to access to the feed {request.FeedId}");
                throw new NewsAggregatorUnauthorizedException(string.Format(Global.CannotAccessToTheFeed, request.FeedId));
            }

            return(await _articleQueryRepository.SearchInFeed(new SearchArticlesInFeedParameter
            {
                Count = request.Count,
                Direction = request.Direction,
                FeedId = request.FeedId,
                Order = request.Order,
                StartIndex = request.StartIndex,
                UserId = request.UserId
            }, cancellationToken));
        }