Пример #1
0
        private void CalculateScore()
        {
            Vote vote =
                Vote.Select(String.Format("USERACCOUNTID = {0} AND FILEID = {1}", _userAccount.Id.ToSqlFormat(),
                                          _file.Id)).FirstOrDefault();
            int positiveVotes = Vote.Count(String.Format("FILEID = {0} AND VOTETYPE = 'Y'", _file.Id.ToSqlFormat()));
            int negativeVotes = Vote.Count(String.Format("FILEID = {0} AND VOTETYPE = 'N'", _file.Id.ToSqlFormat()));

            Debug.WriteLine("{0} - {1}", positiveVotes, negativeVotes);

            if (vote != null)
            {
                bool currentVote = vote.Type;
                if (currentVote)
                {
                    View.LabelScore.ForeColor = Color.Green;
                }

                else
                {
                    View.LabelScore.ForeColor = Color.Red;
                }
            }


            View.LabelScore.Text = (positiveVotes - negativeVotes).ToString();
        }