コード例 #1
0
        public void Update(Goalscorer goalscorer)
        {
            var goalscorerModified = _mapper.Map <Goalscorers>(goalscorer);

            _ctx.Goalscorers.Attach(goalscorerModified);
            _ctx.Entry(goalscorerModified).State = EntityState.Modified;
        }
コード例 #2
0
ファイル: Sync.cs プロジェクト: maxpowersf/FIFA-Backend
        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);
                }
            }
        }
コード例 #3
0
        private async Task <Goalscorer> GetOrCreateGoalscorer(int playerId, int tournamentId)
        {
            var goalscorer = await _goalscorerRepository.GetByPlayerAndTournament(playerId, tournamentId);

            if (goalscorer == null)
            {
                goalscorer = new Goalscorer();
            }

            return(goalscorer);
        }
コード例 #4
0
 public async Task Add(Goalscorer goalscorer)
 {
     var goalscorerToAdd = _mapper.Map <Goalscorers>(goalscorer);
     await _ctx.Goalscorers.AddAsync(goalscorerToAdd);
 }
コード例 #5
0
 public async Task Update(Goalscorer goalscorer)
 {
     _goalscorerRepository.Update(goalscorer);
     await _goalscorerRepository.SaveChanges();
 }