예제 #1
0
        /// <summary>
        /// Get poll information by id
        /// </summary>
        /// <param name="ownerId">Poll owner id</param>
        /// <param name="pollId">Poll id</param>
        /// <returns>Poll information if all ok, null if not ok</returns>
        public PollEntry GetById(int?ownerId, int pollId)
        {
            this.Manager.Method("polls.getById");
            this.Manager.Params("poll_id", pollId);
            if (ownerId != null)
            {
                this.Manager.Params("owner_id", ownerId);
            }

            XmlNode result = this.Manager.Execute().GetResponseXml();

            if (this.Manager.MethodSuccessed)
            {
                XmlUtils.UseNode(result);
                PollEntry p = new PollEntry();
                p.Id          = XmlUtils.Int("poll_id");
                p.OwnerId     = XmlUtils.Int("owner_id");
                p.DateCreated = CommonUtils.FromUnixTime(XmlUtils.Int("created"));
                p.Question    = XmlUtils.String("question");
                p.Votes       = XmlUtils.Int("votes");
                p.AnswerId    = XmlUtils.Int("answer_id");
                p.Answers     = this.buildAnswers(result.SelectNodes("answers/answer"));

                return(p);
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Get poll information by id
        /// </summary>
        /// <param name="ownerId">Poll owner id</param>
        /// <param name="pollId">Poll id</param>
        /// <returns>Poll information if all ok, null if not ok</returns>
        public PollEntry GetById(int? ownerId, int pollId)
        {
            this.Manager.Method("polls.getById");
            this.Manager.Params("poll_id", pollId);
            if (ownerId != null)
            {
                this.Manager.Params("owner_id", ownerId);
            }

            XmlNode result = this.Manager.Execute().GetResponseXml();
            if (this.Manager.MethodSuccessed)
            {
                XmlUtils.UseNode(result);
                PollEntry p = new PollEntry();
                p.Id = XmlUtils.Int("poll_id");
                p.OwnerId = XmlUtils.Int("owner_id");
                p.DateCreated = CommonUtils.FromUnixTime(XmlUtils.Int("created"));
                p.Question = XmlUtils.String("question");
                p.Votes = XmlUtils.Int("votes");
                p.AnswerId = XmlUtils.Int("answer_id");
                p.Answers = this.buildAnswers(result.SelectNodes("answers/answer"));

                return p;
            }

            return null;
        }