Ejemplo n.º 1
0
    private bool TryLoadVoting()
    {
        int id = Id;
        if (id <= 0)
        {
            errorMessage.AddErrorMessage(GetMessage("Error.VoteSelect"));
            ErrorsOnPage = true;
            return false;
        }
        if ((_vote = BXRatingVote.GetById(id, BXTextEncoder.EmptyTextEncoder)) == null)
        {
            errorMessage.AddErrorMessage(GetMessage("Error.VoteSelect"));
            ErrorsOnPage = true;
            return false;
        }

        BXRatingVoting _voting = BXRatingVoting.GetById(_vote.RatingVotingId);

        VotingSubject.ItemId = _voting.RatedItem.Identity;
        VotingSubject.TypeName = _voting.RatedItem.TypeName;
        VotingSubject.DisplayTypeName = true;
        VotingSubject.DataBind();

        //VoteTypeName.Text = this.GetMessage("VotingEntityType."+_voting.RatedItem.TypeName);

        VoteRatingVotingId.Text = @"<a href='VotingView.aspx?id="+_vote.RatingVotingId.ToString()+"'>"
            +_vote.RatingVotingId.ToString()+"</a>";

        VoteCreatedUtc.Text = _vote.CreatedUtc.ToLocalTime().ToString();

        VoteUser.UserID = _vote.UserId.ToString();

        if (!IsPostBack)
        {
            VoteValue.Text = _vote.Value.ToString();
        }
        return true;
    }
Ejemplo n.º 2
0
	public BXRatingVotingTotals Vote(int photoId, string sign)
	{
		if (!EnableVoting || !IsVotingAllowed) return null;
		var photo = BXIBlockElement.GetById(photoId);
		if (photo == null || photo.IBlockId!=IBlockId) return null;

		var desc = new PhotoDescription();
		desc.Element = photo;
		desc.CurUserId = CurrentUserId;

		bool sgn = sign == "true";

		BXRatingVote vote = new BXRatingVote();
		vote.Active = true;

		vote.RatingVotingId = desc.Voting.Id;

		if (desc.VotingTotals.UserHasVoted || !desc.IsVotingAllowed)
		{
			return null;
		}
		//vote.Value = sign ? Voting.Config.PlusValue : Voting.Config.MinusValue;
		vote.Value = sgn ? PositiveVoteValue : NegativeVoteValue;
		vote.UserId = CurrentUserId;
		vote.UserIP = Request.UserHostAddress;

		vote.Create();
		desc.VotingTotals = null;
		return desc.VotingTotals;
	}