Source

stacky / trunk / source / Stacky.Net35 / StackyClient / CommentMethods.cs

using System;
using System.Collections.Generic;

namespace Stacky
{
    public partial class StackyClient
    {
        public virtual IPagedList<Comment> GetComments(IEnumerable<int> fromUserIds)
        {
            return GetComments(fromUserIds, new CommentOptions());
        }

        public virtual IPagedList<Comment> GetComments(IEnumerable<int> fromUserIds, CommentOptions options)
        {
            string[] urlParameters = null;
            if (options.ToUserId.HasValue)
            {
                urlParameters = new string[] { fromUserIds.Vectorize(), "comments", options.ToUserId.ToString() };
            }
            else
            {
                urlParameters = new string[] { fromUserIds.Vectorize(), "comments" };
            }

            var response = MakeRequest<Comment>("users", urlParameters, new
            {
                site = this.SiteUrlName,
                page = options.Page ?? null,
                pagesize = options.PageSize ?? null,
                fromdate = GetDateValue(options.FromDate),
                todate = GetDateValue(options.ToDate),
                sort = options.SortBy.ToString().ToLower(),
                order = GetSortDirection(options.SortDirection),
                min = options.Min ?? null,
                max = options.Max ?? null
            });
            return new PagedList<Comment>(response);
        }

        public virtual IPagedList<Comment> GetComments(int fromUserId)
        {
            return GetComments(fromUserId.ToArray(), new CommentOptions());
        }

        public virtual IPagedList<Comment> GetComments(int fromUserId, CommentOptions options)
        {
            return GetComments(fromUserId.ToArray(), options);
        }

        public virtual IPagedList<Comment> GetCommentsByPost(int postId)
        {
            return GetCommentsByPost(postId, new CommentsByPostOptions());
        }

        public virtual IPagedList<Comment> GetCommentsByPost(int postId, CommentsByPostOptions options)
        {
            return GetCommentsByPost(postId.ToArray(), options);
        }

        public virtual IPagedList<Comment> GetCommentsByPost(IEnumerable<int> postIds)
        {
            return GetCommentsByPost(postIds, new CommentsByPostOptions());
        }

        public virtual IPagedList<Comment> GetCommentsByPost(IEnumerable<int> postIds, CommentsByPostOptions options)
        {
            var response = MakeRequest<Comment>("posts", new string[] { postIds.Vectorize(), "comments" }, new
            {
                site = this.SiteUrlName,
                page = options.Page ?? null,
                pagesize = options.PageSize ?? null,
                fromdate = GetDateValue(options.FromDate),
                todate = GetDateValue(options.ToDate),
                sort = options.SortBy.ToString().ToLower(),
                order = GetSortDirection(options.SortDirection),
            });
            return new PagedList<Comment>(response);
        }

        public virtual IPagedList<Comment> GetAnswerComments(int answerId)
        {
            return GetAnswerComments(answerId, new CommentsByPostOptions());
        }

        public virtual IPagedList<Comment> GetAnswerComments(int answerId, CommentsByPostOptions options)
        {
            return GetAnswerComments(answerId.ToArray(), options);
        }

        public virtual IPagedList<Comment> GetAnswerComments(IEnumerable<int> answerIds)
        {
            return GetAnswerComments(answerIds, new CommentsByPostOptions());
        }

        public virtual IPagedList<Comment> GetAnswerComments(IEnumerable<int> answerIds, CommentsByPostOptions options)
        {
            var response = MakeRequest<Comment>("answers", new string[] { answerIds.Vectorize(), "comments" }, new
            {
                site = this.SiteUrlName,
                page = options.Page ?? null,
                pagesize = options.PageSize ?? null,
                fromdate = GetDateValue(options.FromDate),
                todate = GetDateValue(options.ToDate),
                sort = options.SortBy.ToString().ToLower(),
                order = GetSortDirection(options.SortDirection),
                min = options.Min ?? null,
                max = options.Max ?? null
            });
            return new PagedList<Comment>(response);
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.