Пример #1
0
        /// <summary>
        /// Populates poll's results
        /// </summary>
        /// <param name="userStatus">User status (e.g. anonymous; signed-in)</param>
        /// <param name="response">Response index</param>
        /// <param name="key">Attribute name</param>
        /// <param name="value">Attribute value</param>
        /// <remarks>Collection later used by the code which generates xml. Attribute keys and values will end up as &lt;OPTION&gt; element xml attributes (key="value")</remarks>
		public void Add(Poll.UserStatus userStatus, int response, string key, string value)
        {
            Options pollOptions;
            bool exists = _results.TryGetValue(userStatus, out pollOptions); 
            if (!exists)
            {
                pollOptions = new Options();
                _results.Add(userStatus, pollOptions); 
            }

            OptionAttributes optionAttributes;
            exists = pollOptions.TryGetValue(response, out optionAttributes);
            if (!exists)
            {
                optionAttributes = new OptionAttributes();
                pollOptions.Add(response, optionAttributes); 
            }

            // If key does not exist then new key/value pair added.
            optionAttributes[key] = value; 
        }
Пример #2
0
        /// <summary>
        /// Link a poll with an item (e.g. article, club etc...)
        /// </summary>
        /// <param name="itemID">Id of item</param>
        /// <param name="itemType">Type of item</param>
        /// <returns>Success</returns>
        public bool LinkPollWithItem(int itemID, Poll.ItemType itemType)
        {
            // Poll must be created
            if (PollID == -1)
            {
                return false;
            }

            if (!LinkPoll(itemID, itemType))
            {
                return AddErrorXml("Link Poll", "Can not link poll with item.", null);

            }
            return true;
        }