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

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

            return(CommentRepository.GetCountByPostId(id));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }