Ejemplo n.º 1
0
 public void CalculatePlayerResult(Player playerInput)
 {
     using (var dc = ThaitaeDataDataContext.Create())
     {
         var playerTeamList =
             dc.Players.Where(item => item.SeasonId == playerInput.SeasonId && item.TeamId == playerInput.TeamId).ToList();
         foreach (var player in playerTeamList)
         {
             var playerUpdate = dc.Players.Single(item => item.PlayerId == player.PlayerId);
             playerUpdate.PlayerGoal =
                 dc.PlayerMatches.Count(
                     item =>
                     item.PlayerGoal == 1 && item.PlayerId == player.PlayerId && item.TeamId == player.TeamId && item.SeasonId == player.SeasonId);
             playerUpdate.PlayerRedCard =
                 dc.PlayerMatches.Count(
                     item =>
                     item.PlayerRedCard == 1 && item.PlayerId == player.PlayerId && item.TeamId == player.TeamId && item.SeasonId == player.SeasonId);
             playerUpdate.PlayerYellowCard =
                 dc.PlayerMatches.Count(
                     item =>
                     item.PlayerYellowCard == 1 && item.PlayerId == player.PlayerId && item.TeamId == player.TeamId && item.SeasonId == player.SeasonId);
             dc.SubmitChanges();
         }
     }
 }
Ejemplo n.º 2
0
 public Player CalculatePlayerMatch(int playerMatchId, int playerNumber, string playerName)
 {
     Player playerUpdate;
     using (var dc = ThaitaeDataDataContext.Create())
     {
         var playerMatch = dc.PlayerMatches.Single(item => item.PlayerMatchId == playerMatchId);
         var playerCheck =
             dc.Players.Count(
                 item =>
                 item.SeasonId == playerMatch.SeasonId && item.TeamId == playerMatch.TeamId &&
                 item.PlayerNumber == playerNumber);
         if (playerCheck == 0)
         {
             var player = new Player
             {
                 PlayerNumber = playerNumber,
                 PlayerName = playerName,
                 TeamId = playerMatch.TeamId,
                 SeasonId = playerMatch.SeasonId
             };
             dc.Players.InsertOnSubmit(player);
             dc.SubmitChanges();
             playerMatch.PlayerId = player.PlayerId;
             dc.SubmitChanges();
             playerUpdate = player;
         }
         else
         {
             var player =
             dc.Players.Single(
                 item =>
                 item.SeasonId == playerMatch.SeasonId && item.TeamId == playerMatch.TeamId &&
                 item.PlayerNumber == playerNumber);
             playerMatch.PlayerId = player.PlayerId;
             playerMatch.PlayerId = player.PlayerId;
             if (!string.IsNullOrEmpty(playerName))
             {
                 player.PlayerName = playerName;
             }
             dc.SubmitChanges();
             playerUpdate = player;
         }
     }
     return playerUpdate;
 }
Ejemplo n.º 3
0
 partial void DeletePlayer(Player instance);
Ejemplo n.º 4
0
 partial void UpdatePlayer(Player instance);
Ejemplo n.º 5
0
 partial void InsertPlayer(Player instance);
Ejemplo n.º 6
0
		private void detach_Players(Player entity)
		{
			this.SendPropertyChanging();
			entity.Team = null;
		}
Ejemplo n.º 7
0
		private void attach_Players(Player entity)
		{
			this.SendPropertyChanging();
			entity.Team = this;
		}