Exemplo n.º 1
0
        public async Task Update(ChampionshipGame championshipGame)
        {
            var BDChampionshipGame = _ctx.ChampionshipGame
                                     .FirstOrDefault(x => x.Id == championshipGame.Id);


            BDChampionshipGame.UpdateChampionshipGame(championshipGame);
            await _ctx.SaveChangesAsync();
        }
        private List <ChampionshipGame> CreateChampionshipGames(Championship championship)
        {
            List <ChampionshipGame> lstChampionshipGames = new List <ChampionshipGame>();

            foreach (var homeTeam in championship.Teams)
            {
                foreach (var awayTeam in championship.Teams.Where(x => x.Id != homeTeam.Id).ToList())
                {
                    ChampionshipGame championshipGame = new ChampionshipGame(championship, homeTeam, awayTeam);
                    lstChampionshipGames.Add(championshipGame);
                }
            }
            return(lstChampionshipGames);
        }
Exemplo n.º 3
0
        public async Task <ResponseApi> Handle(UpdateChampionshipGameCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Update Championship Game : { JsonSerializer.Serialize(request)}");
            try
            {
                ChampionshipGame championshipGame = new ChampionshipGame(request.Id, request.HomeScore, request.AwayScore, request.GameDate);
                await _championshipGameRepository.Update(championshipGame);


                var response = new { Id = championshipGame.Id, HomeScore = championshipGame.HomeScore, AwayScore = championshipGame.AwayScore, GameDate = championshipGame.GameDate };
                _logger.LogInformation($"SUCCESS - Update Championship Game : { JsonSerializer.Serialize(response)}");

                return(new ResponseApi(true, "Jogo Atualizado com Sucesso",
                                       response));
            }
            catch (Exception e)
            {
                _logger.LogInformation($"ERROR - Update Championship Game : { JsonSerializer.Serialize(e)}");
                return(new ResponseApi(false, "Erro ao atualizar o jogo", e.InnerException.ToString()));
            }
        }