Exemple #1
0
        public int GetCommentCountByPostId(int id)
        {
            var comments = CacheRepository.GetItems <Comment>($"{CommentsByPostIdCache}-{id}");

            if (comments != null)
            {
                return(comments.Count());
            }

            return(CommentRepository.GetCountByPostId(id));
        }
Exemple #2
0
        public IEnumerable <Comment> GetCommentsWithTools(OptionsCollectionById options)
        {
            var comments = CacheRepository.GetItems <Comment>(GetOptionsString(options));

            if (comments != null)
            {
                return(comments);
            }

            comments = CommentRepository.GetWithOptions(options);
            CacheRepository.Add(comments, GetOptionsString(options));
            return(comments);
        }
Exemple #3
0
        public IEnumerable <Comment> GetCommentsByPostId(int id)
        {
            var comments = CacheRepository.GetItems <Comment>($"{CommentsByPostIdCache}-{id}");

            if (comments != null)
            {
                return(comments);
            }

            comments = CommentRepository.GetByPostId(id).Reverse();
            CacheRepository.Add(comments, $"{CommentsByPostIdCache}-{id}");
            return(comments);
        }