public async Task <SingleLeagueMatchModel> ResetMatch(SingleLeagueMatchModel singleLeagueMatchModel, int matchId) { CancellationToken ct = new(); if (singleLeagueMatchModel == null) { throw new ArgumentNullException(nameof(singleLeagueMatchModel)); } var allGoals = _context.SingleLeagueGoals.Where(x => x.MatchId == matchId).ToList(); var tx = await _context.Database.BeginTransactionAsync(ct); string sqlString = $"DELETE FROM single_league_goals WHERE match_id = {matchId}"; await _context.ExecuteAsync(ct, sqlString); await tx.CommitAsync(ct); singleLeagueMatchModel.StartTime = null; singleLeagueMatchModel.EndTime = null; singleLeagueMatchModel.PlayerOneScore = 0; singleLeagueMatchModel.PlayerTwoScore = 0; singleLeagueMatchModel.MatchStarted = false; singleLeagueMatchModel.MatchEnded = false; singleLeagueMatchModel.MatchPaused = false; _context.SingleLeagueMatches.Update(singleLeagueMatchModel); _context.SaveChanges(); return(singleLeagueMatchModel); }
private void UpdateSingleLeagueMatchScore(SingleLeagueMatchModel matchToChange, SingleLeagueGoalModel singleLeagueGoalModel) { if (matchToChange.PlayerOne == singleLeagueGoalModel.ScoredByUserId) { if (matchToChange.PlayerOneScore > 0) { matchToChange.PlayerOneScore -= 1; } } if (matchToChange.PlayerTwo == singleLeagueGoalModel.ScoredByUserId) { if (matchToChange.PlayerTwoScore > 0) { matchToChange.PlayerTwoScore -= 1; } } _context.SingleLeagueMatches.Update(matchToChange); }
public void UpdateSingleLeagueMatch(SingleLeagueMatchModel match) { // Do nothing }