コード例 #1
0
 protected bool Equals(ScoreTableLine other)
 {
     var a = Points == other.Points &&
             Bonus == other.Bonus &&
             TotalPoints == other.TotalPoints &&
             Games == other.Games &&
             Won == other.Won &&
             Draw == other.Draw &&
             Lost == other.Lost &&
             Forfait == other.Forfait &&
             PositivePoints == other.PositivePoints &&
             NegativePoints == other.NegativePoints &&
             RedCards == other.RedCards &&
             TeamclubId == other.TeamclubId &&
             //Equals(TeamClub, other.TeamClub) &&
             AuditDeleted.Equals(other.AuditDeleted) &&
             Order == other.Order &&
             InternalOrder == other.InternalOrder;
     return a;
 }
コード例 #2
0
        private ICollection<ScoreTableLine> LoadTableForTeam(Team team, DAL.ScoreTable table, DAL.AntwerpRCEntities context, string user, DateTime calculationDate)
        {
            try
            {
                var returnLines = new List<ScoreTableLine>();

                var teamClubs = team.TeamClub.Where(tc => !tc.AuditDeleted);
                foreach (var teamClub in teamClubs)
                {
                    var tableLine = new ScoreTableLine();
                    tableLine.TeamclubId = teamClub.TeamClubId;
                    tableLine.TeamClub = teamClub;
                    tableLine.AuditCreatedBy = user;
                    tableLine.AuditCreatedOn = DateTime.Now;

                    var gamesForTeam =
                        context.Game.Where(
                            g =>
                                (g.TeamClub1Id == teamClub.TeamClubId || g.TeamClub2Id == teamClub.TeamClubId) &&
                                g.Date < calculationDate);
                    foreach (var game in gamesForTeam)
                    {
                        //Check for forfait
                        if (game.TeamClub1Score == -1 || game.TeamClub2Score == -1)
                        {
                            if (game.TeamClub1Id == teamClub.TeamClubId)
                            {
                                if (game.TeamClub1Score == -1)
                                {
                                    //The current team is givving forfait
                                    tableLine.Forfait++;
                                    tableLine.Points -= 2;
                                    tableLine.NegativePoints += 25;
                                    tableLine.PositivePoints += 0;
                                }
                                else
                                {
                                    //The current team is NOT givving forfait
                                    tableLine.Won++;
                                    tableLine.Points += 4;
                                    tableLine.Bonus += 1;
                                    tableLine.PositivePoints += 25;
                                    tableLine.NegativePoints += 0;
                                }
                            }
                            else
                            {
                                if (game.TeamClub2Score == -1)
                                {
                                    //This team is giving forfait
                                    tableLine.Forfait++;
                                    tableLine.Points -= 2;
                                    tableLine.NegativePoints += 25;
                                    tableLine.PositivePoints += 0;
                                }
                                else
                                {
                                    tableLine.Won++;
                                    tableLine.Points += 4;
                                    tableLine.Bonus += 1;
                                    tableLine.PositivePoints += 25;
                                    tableLine.NegativePoints += 0;
                                }
                            }
                            tableLine.Games++;
                            continue;
                        }
                        if (game.TeamClub1Score >= 0 && game.TeamClub2Score >= 0)
                        {
                            if (game.TeamClub1Score == game.TeamClub2Score)
                            {
                                //Draw
                                tableLine.Points += 2;
                                tableLine.Draw++;
                                tableLine.PositivePoints += game.TeamClub1Score.Value;
                                tableLine.NegativePoints += game.TeamClub1Score.Value;

                                if (game.TeamClub1Id == teamClub.TeamClubId && game.TeamClub1Tries >= 4)
                                {
                                    tableLine.Bonus++;
                                }
                                if (game.TeamClub2Id == teamClub.TeamClubId && game.TeamClub2Tries >= 4)
                                {
                                    tableLine.Bonus++;
                                }
                            }
                            else if (game.TeamClub1Score > game.TeamClub2Score)
                            {
                                if (game.TeamClub1Id == teamClub.TeamClubId)
                                {
                                    //Team 1 won, check if it's the team we're calculating
                                    tableLine.Points += 4;
                                    tableLine.Won++;
                                    tableLine.PositivePoints += game.TeamClub1Score.Value;
                                    tableLine.NegativePoints += game.TeamClub2Score.Value;
                                    if (game.TeamClub1Tries >= 4)
                                        tableLine.Bonus++;
                                }
                                else
                                {
                                    tableLine.Lost++;
                                    tableLine.PositivePoints += game.TeamClub2Score.Value;
                                    tableLine.NegativePoints += game.TeamClub1Score.Value;
                                    if (game.TeamClub1Score - game.TeamClub2Score <= 7)
                                        tableLine.Bonus++;
                                    else if (game.TeamClub2Tries >= 4)
                                        tableLine.Bonus++;
                                }
                            }
                            else
                            {
                                //Team 2 won, check if it's the team we're calculating
                                if (game.TeamClub2Id == teamClub.TeamClubId)
                                {
                                    tableLine.Points += 4;
                                    tableLine.Won++;
                                    tableLine.PositivePoints += game.TeamClub2Score.Value;
                                    tableLine.NegativePoints += game.TeamClub1Score.Value;
                                    if (game.TeamClub2Tries >= 4)
                                        tableLine.Bonus++;
                                }
                                else
                                {
                                    tableLine.Lost++;
                                    tableLine.PositivePoints += game.TeamClub1Score.Value;
                                    tableLine.NegativePoints += game.TeamClub2Score.Value;
                                    if (game.TeamClub2Score - game.TeamClub1Score <= 7)
                                        tableLine.Bonus++;
                                    else if (game.TeamClub1Tries >= 4)
                                        tableLine.Bonus++;
                                }
                            }
                        }
                        tableLine.Games++;
                    }
                    tableLine.TotalPoints = tableLine.Points + tableLine.Bonus;
                    table.ScoreTableLine.Add(tableLine);
                    tableLine.ScoreTable = table;
                    returnLines.Add(tableLine);
                }
                return SetOrderInTable(returnLines);
            }
            catch (Exception ex)
            {
                throw;
            }
        }