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())); } }
public async Task <IActionResult> Put([FromBody] UpdateChampionshipGameCommand updateChampionshipGameCommand) { var response = await _mediator.Send(updateChampionshipGameCommand); return(Ok(response)); }