Ejemplo n.º 1
0
        private void AddPoints(SquashContext context, DBPlayer player, DateTime date, string points)
        {
            var dbPoints = new Points {
                Date = date, Number = points
            };

            player.Points.Add(dbPoints);
        }
Ejemplo n.º 2
0
 private DBPlayer CreatePlayer(SquashContext context, string player, DBPlayer dbPlayer)
 {
     if (dbPlayer != null)
     {
         return(dbPlayer);
     }
     dbPlayer = new DBPlayer(player);
     context.Players.Add(dbPlayer);
     context.SaveChanges();
     return(dbPlayer);
 }
Ejemplo n.º 3
0
 private void AddResults(SquashContext context, DBPlayer player1, DBPlayer player2, string[] results, Tournament tournament)
 {
     foreach (var result in results)
     {
         var score = result.Split(":");
         int homeScore, awayScore;
         if (int.TryParse(score[0], out homeScore) && int.TryParse(score[1], out awayScore))
         {
             var match = new Match {
                 IsTraining = false, IsJogo = true, Player1 = player1, Player2 = player2, Games = { new Game {
                                                                                                        Player1Score = homeScore, Player2Score = awayScore
                                                                                                    } }
             };
             tournament.Matches.Add(match);
             //context.Games.Add(new Game { Player1 = player1, Player2 = player2, Player1Score = homeScore, Player2Score = awayScore, Tournament = tournament });
         }
     }
     context.SaveChanges();
 }