コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 public void UpdateSingleLeagueMatch(SingleLeagueMatchModel match)
 {
     // Do nothing
 }