コード例 #1
0
        public FeedDTO GetFeed(string title, string publishDate)
        {
            var feed = feedCacheManager.Get(title);

            if (feed == null)
            {
                feed = feedRepository.GetFeed(title, publishDate);
                feedCacheManager.Set(title, feed);
            }
            return(Mapper.Map <FeedDTO>(feed));
        }
コード例 #2
0
ファイル: FeedsController.cs プロジェクト: phumad/newsfeed
        public HttpResponseMessage Get(int id)
        {
            var f = feedRepository.GetFeed(id);

            if (f == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, string.Format("Feed with id {0} not found", id)));
            }
            return(Request.CreateResponse(f.Body));
        }
コード例 #3
0
        public async Task <List <PublicationViewModel> > GetFeed(Guid userId, int amount, Guid?positionId, Guid?requestUserId)
        {
            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), "Amount must be greater than 0");
            }
            if (amount > MaxPublicationAmount)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), $"Amount cannot be greater than {MaxPublicationAmount}");
            }

            if (!await UserService.Exists(userId))
            {
                throw new UserNotFoundException("User not found");
            }
            if (positionId.HasValue && !await PublicationService.Exists(positionId.Value))
            {
                throw new DataNotFoundException($"{positionId.Value.ToString()} does not exists.");
            }

            return((await FeedRepository.GetFeed(userId, amount, positionId, requestUserId)).ToList());
        }
コード例 #4
0
 public Feed GetFeed(System.Int32 FeedId)
 {
     return(_iFeedRepository.GetFeed(FeedId));
 }
コード例 #5
0
 public List <FeedEvent> GetFeed(User user)
 {
     return(_feedRepository.GetFeed(user.UserID, MaxFeedCount));
 }
コード例 #6
0
 public async Task <List <FeedEvent> > GetFeed(User user)
 {
     return(await _feedRepository.GetFeed(user.UserID, MaxFeedCount));
 }