예제 #1
0
        /// <summary>
        /// Registers a vote for the given access token and decrements the count of the remainig votes.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// There are no votes left for the given access token, or a the same entry is registered twice.
        /// </exception>
        public void RegisterVote(Guid accessToken, PlaylistEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            this.VerifyVotingPreconditions(accessToken);

            AccessEndPoint endPoint = this.VerifyAccessToken(accessToken);

            if (!endPoint.RegisterEntry(entry) && !entry.IsShadowVoted)
            {
                throw new InvalidOperationException("Entry already registered");
            }
        }
예제 #2
0
        /// <summary>
        /// Registers a vote for the given access token and decrements the count of the remainig votes.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// There are no votes left for the given access token, or a the same entry is registered twice.
        ///
        /// -- or--
        ///
        /// The access token isn't a guest token.
        /// </exception>
        public void RegisterShadowVote(Guid accessToken, PlaylistEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            if (!entry.IsShadowVoted)
            {
                throw new ArgumentException("Entry must be shadow voted");
            }

            this.VerifyVotingPreconditions(accessToken);

            AccessEndPoint endPoint = this.VerifyAccessToken(accessToken);

            if (endPoint.AccessPermission.FirstAsync().Wait() != AccessPermission.Guest)
            {
                throw new InvalidOperationException("Access token has to be a guest token.");
            }

            endPoint.RegisterEntry(entry);
        }