public TournamentPromotion()
 {
     Title            = string.Empty;
     TournamentLeft   = new TournamentInfo();
     TournamentMiddle = new TournamentInfo();
     TournamentRight  = new TournamentInfo();
 }
Esempio n. 2
0
        private static int Compare(TournamentInfo firstObject, TournamentInfo secondObject)
        {
            if (firstObject.status.ToLower() == "inprogress" && secondObject.status.ToLower() != "inprogress")
            {
                return(-1);
            }
            else
            {
                if (firstObject.status.ToLower() == "inprogress" && secondObject.status.ToLower() == "inprogress")
                {
                    if (firstObject.maxPlayers > secondObject.maxPlayers)
                    {
                        return(-1);
                    }
                    else
                    {
                        if (firstObject.maxPlayers < secondObject.maxPlayers)
                        {
                            return(1);
                        }
                    }
                }
                else
                {
                    if (firstObject.status.ToLower() != "inprogress" && secondObject.status.ToLower() == "inprogress")
                    {
                        return(1);
                    }
                }
            }

            if (firstObject.status == "inPreparation" && secondObject.status != "inPreparation")
            {
                return(-1);
            }
            else
            {
                if (firstObject.status == "inPreparation" && secondObject.status == "inPreparation")
                {
                    return(0);
                }
                else
                {
                    if (firstObject.status != "inPreparation" && secondObject.status == "inPreparation")
                    {
                        return(2);
                    }
                }
            }


            if (firstObject.startTime == null)
            {
                firstObject.startTime = firstObject.createTime;
            }

            if (secondObject.startTime == null)
            {
                secondObject.startTime = secondObject.createTime;
            }

            var datetimeFirst = new DateTime(1970, 1, 1, 0, 0, 0, 0)
                                .AddSeconds(long.Parse(firstObject.startTime.ToString())).ToLocalTime();

            var datetimeSecond = new DateTime(1970, 1, 1, 0, 0, 0, 0)
                                 .AddSeconds(long.Parse(secondObject.startTime.ToString())).ToLocalTime();



            return(datetimeSecond.CompareTo(datetimeFirst));
        }