private async Task UpdatePlayerPointsAsync( PlayerForUpdateDto playerInDb, IDictionary <int, int> clubsIdAndMatchdayPairsInFixtureForUpdate) { var clubId = playerInDb.ClubId; var matchday = clubsIdAndMatchdayPairsInFixtureForUpdate[clubId]; var playersPointsInMatchdayDto = new PlayersPointsInMatchdayDto { Matchday = matchday, PlayerId = playerInDb.Id, Points = playerInDb.Points, }; await this.pointsService.AddPlayersPointByFixtureAsync(playersPointsInMatchdayDto); }
public async Task AddPlayersPointByFixtureAsync(PlayersPointsInMatchdayDto playersPointsDto) { var playersPoints = new PlayerPointsByFixture { Matchday = playersPointsDto.Matchday, PlayerId = playersPointsDto.PlayerId, Points = playersPointsDto.Points, }; if (!this.playersPointsRepo.AllAsNoTracking().Any(x => x.PlayerId == playersPoints.PlayerId && x.Matchday == playersPoints.Matchday)) { await this.playersPointsRepo.AddAsync(playersPoints); await this.playersPointsRepo.SaveChangesAsync(); } }