Exemple #1
0
        private int Comparison(ContestParticipant x, ContestParticipant y)
        {
            // Return -1 = X is greater then Y (Put x above Y)
            // Return 1 = Y is greater then X (Put y above x)

            if (x.Points < y.Points)
            {
                return(1);
            }
            else if (x.Points == y.Points)
            {
                // Compare the Last Activity Date to see who got to the points value first.
                DateTime xLastActvity  = x.LatestAction;
                DateTime yLastActivity = y.LatestAction;
                int      result        = DateTime.Compare(xLastActvity, yLastActivity);

                if (result < 0) //X Time is earlier then Y Time
                {
                    return(-1);
                }
                else if (result == 0) //X Time is the same as Y Time (Leave X on Top)
                {
                    return(1);
                }
                else //X Time is later then Y Time
                {
                    return(1);
                }
            }
            else
            {
                return(-1);
            }
        }
Exemple #2
0
 public void Participate(Member User)
 {
     if (CanMemberParticipate(User))
     {
         var cp = new ContestParticipant();
         cp.ContestId    = this.Id;
         cp.LatestAction = DateTime.Now;
         cp.Points       = new Money(0);
         cp.Username     = User.Name;
         cp.Save();
     }
 }
Exemple #3
0
        /// <summary>
        /// Fires when member made any action which can be applied for a contest. It checks if memeber
        /// is participating in any contests. If so, the contest data is being updated.
        /// Leave one credit NULL (int=0 or money=NULL)
        /// </summary>
        /// <param name="ActionType"></param>
        /// <returns></returns>
        public static void IMadeAnAction(ContestType ActionType, string Username,
                                         Money MoneyCredit, int IntCredit)
        {
            List <Contest> ContestList = GetMemberParticipatingContests(ActionType, Username);

            foreach (var contest in ContestList)
            {
                if (ActionType == ContestType.Transfer && contest.MinMembersDeposit > MoneyCredit)
                {
                    continue;
                }

                var participant = ContestParticipant.GetParticipant(contest, Username);
                participant.Credit(IntCredit, MoneyCredit);
                participant.Save();
            }
        }