public void Update(Goalscorer goalscorer) { var goalscorerModified = _mapper.Map <Goalscorers>(goalscorer); _ctx.Goalscorers.Attach(goalscorerModified); _ctx.Entry(goalscorerModified).State = EntityState.Modified; }
private void ProcessData(Tournament tournament) { foreach (GoalscorerSync goalscorer in GoalscorersInExcel) { try { Player player = _playerService.Get(goalscorer.Player, goalscorer.Team).Result; if (player == null) { ConsoleMessage($"Player: {goalscorer.Player} - Player not found", ConsoleColor.DarkRed); continue; } Goalscorer newGoalscorer = new Goalscorer { TournamentID = tournament.Id, PlayerID = player.Id, Goals = goalscorer.Goals, GoldenBoot = goalscorer.GoldenBoot }; GoalscorersToAdd.Add(newGoalscorer); } catch (Exception ex) { ConsoleMessage($"Player: {goalscorer.Player} - Error processing data: {ex.Message}", ConsoleColor.DarkRed); } } }
private async Task <Goalscorer> GetOrCreateGoalscorer(int playerId, int tournamentId) { var goalscorer = await _goalscorerRepository.GetByPlayerAndTournament(playerId, tournamentId); if (goalscorer == null) { goalscorer = new Goalscorer(); } return(goalscorer); }
public async Task Add(Goalscorer goalscorer) { var goalscorerToAdd = _mapper.Map <Goalscorers>(goalscorer); await _ctx.Goalscorers.AddAsync(goalscorerToAdd); }
public async Task Update(Goalscorer goalscorer) { _goalscorerRepository.Update(goalscorer); await _goalscorerRepository.SaveChanges(); }