public MatchGoal EditMatchGoal(MatchGoal thisMatchGoal) { if (_context.Match_Goals.Find(thisMatchGoal.Id) != null) { var updatedMatchGoal = _context.Match_Goals.Attach(thisMatchGoal); updatedMatchGoal.State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(thisMatchGoal); } return(thisMatchGoal); }
public int Insert(MatchGoal matchGoal) { return(Add(INSERT, new Dictionary <string, object> { { "matchId", matchGoal.MatchId }, { "teamId", matchGoal.TeamId }, { "minute", matchGoal.Minute }, { "playerId", matchGoal.PlayerId }, { "assistPlayerId", matchGoal.AssistPlayerId }, { "ownGoal", matchGoal.OwnGoal } })); }
// Primitive private void CreateGoalRecord(int matchId, int teamId) { var minute = Utilities.Utilities.GetRandomNumber(1, 90); var playerId = _playerService.GetRandomPlayerFromTeam(teamId, false); var assistPlayerId = _playerService.GetRandomPlayerFromTeam(teamId); if (playerId == assistPlayerId) { assistPlayerId = 0; } var ownGoal = false; var matchGoal = new MatchGoal { MatchId = matchId, TeamId = teamId, PlayerId = playerId, AssistPlayerId = assistPlayerId, Minute = minute, OwnGoal = ownGoal // TODO - some of these }; _matchGoalService.Insert(matchGoal); if (!ownGoal) { var playerStats = _playerStatsService.Get(playerId); playerStats.Goals++; _playerStatsService.Update(playerStats); } if (assistPlayerId > 0) { var playerAssistStats = _playerStatsService.Get(assistPlayerId); playerAssistStats.Assists++; _playerStatsService.Update(playerAssistStats); } }
public int Insert(MatchGoal matchGoal) { return(_matchGoalQuery.Insert(matchGoal)); }
public MatchGoal AddMatchGoal(MatchGoal matchGoal) { _context.Match_Goals.Add(matchGoal); return(matchGoal); }