public Task <bool> Handle(ActivateGameCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyValidationErrors(command); return(Task.FromResult(false)); } var game = gameReadRepository.GetById(command.Id); if (game.Active) { mediator.RaiseEventAsync(new DomainNotification(command.MessageType, "O jogo já está ativo!")); return(Task.FromResult(false)); } game.Activate(); gameWriteRepository.Update(game); if (Commit()) { mediator.RaiseEventAsync(new ActivateGameEvent(game.Id)); } return(Task.FromResult(true)); }
public GameViewModel GetById(Guid id) { var result = gameReadRepository.GetById(id); return(mapper.Map <GameViewModel>(gameReadRepository.GetById(id))); }