public async Task <bool> Handle(UpdateTournamentInfo command, CancellationToken cancellationToken = default(CancellationToken)) { var tournament = await _context.Tournaments.FindAsync(command.Id); tournament.UpdateInfo(command.Title, command.StartDate, command.EndDate); return(await _context.SaveChangesAsync(cancellationToken) > 0); }
public async Task <IActionResult> UpdateTournament(int id, [FromBody] TournamenWriteDto tournament) { var updateTournament = new UpdateTournamentInfo(id, tournament.Title, tournament.StartDate, tournament.EndDate); var isCompletedSuccessfully = await _mediator.Send(updateTournament); if (isCompletedSuccessfully) { return(new StatusCodeResult(StatusCodes.Status201Created)); } else { return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }