/// <inheritdoc /> public async Task <IList <BowlingFigures> > UpdateBowlingFigures(MatchInnings innings, Guid memberKey, string memberName, IDbTransaction transaction) { if (innings is null) { throw new ArgumentNullException(nameof(innings)); } if (string.IsNullOrWhiteSpace(memberName)) { throw new ArgumentNullException(nameof(memberName)); } if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } var i = 1; foreach (var bowlingFigures in innings.BowlingFigures) { if (!bowlingFigures.BowlingFiguresId.HasValue) { bowlingFigures.BowlingFiguresId = Guid.NewGuid(); } if (bowlingFigures.Bowler == null) { throw new ArgumentException($"{nameof(bowlingFigures.Bowler)} cannot be null in a {typeof(BowlingFigures)}"); } if (innings.MatchInningsId == null) { throw new ArgumentException($"{nameof(innings.MatchInningsId)} cannot be null in a {typeof(MatchInnings)}"); } bowlingFigures.Bowler = await _playerRepository.CreateOrMatchPlayerIdentity(bowlingFigures.Bowler, memberKey, memberName, transaction).ConfigureAwait(false); await transaction.Connection.ExecuteAsync($@"INSERT INTO {Tables.BowlingFigures} (BowlingFiguresId, MatchInningsId, BowlingOrder, BowlerPlayerIdentityId, Overs, Maidens, RunsConceded, Wickets, IsFromOversBowled) VALUES (@BowlingFiguresId, @MatchInningsId, @BowlingOrder, @BowlerPlayerIdentityId, @Overs, @Maidens, @RunsConceded, @Wickets, @IsFromOversBowled)", new { bowlingFigures.BowlingFiguresId, innings.MatchInningsId, BowlingOrder = i, BowlerPlayerIdentityId = bowlingFigures.Bowler.PlayerIdentityId, bowlingFigures.Overs, bowlingFigures.Maidens, bowlingFigures.RunsConceded, bowlingFigures.Wickets, IsFromOversBowled = true }, transaction).ConfigureAwait(false); i++; } return(innings.BowlingFigures); }