//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using CommunityServer;

namespace CommunityServer.Components
{
	public class PollVote
	{
		private PollSummary poll;
		private int userID;
		private string answerID;
		private User user;

		public PollVote(PollSummary poll, int userID, string answerID)
		{
			this.poll = poll;
			this.userID = userID;
			this.answerID = answerID;
		}

		public string AnswerID
		{
			get { return answerID; }
		}

		public string Answer
		{
			get { return poll.GetPollItemByAnswerID(AnswerID).Answer; }
		}

		public int UserID
		{
			get { return userID; }
		}

		public User User
		{
			get
			{
				if (user == null)
					user = Users.GetUser(UserID, false);

				return user;
			}
		}

		public string Username
		{
			get { return this.User.Username; }
		}

		public string ViewUserURL
		{
			get { return SiteUrls.Instance().UserProfile(this.User.Username); }
		}

		public string UserEmail
		{
			get { return this.User.Email; }
		}

		public string UserDisplayName
		{
			get { return this.User.DisplayName; }
		}
	}
}
