コード例 #1
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()));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Put([FromBody] UpdateChampionshipGameCommand updateChampionshipGameCommand)
        {
            var response = await _mediator.Send(updateChampionshipGameCommand);

            return(Ok(response));
        }