Example #1
0
        public async Task <List <PublicationViewModel> > GetMainFeed(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 (positionId.HasValue && !await PublicationService.Exists(positionId.Value))
            {
                throw new DataNotFoundException($"{positionId.Value} does not exists.");
            }

            return((await FeedRepository.GetMainFeed(amount, positionId, requestUserId)).ToList());
        }