public async Task <CommandResult> Handle(ExcluirSalaCommand command, CancellationToken cancellationToken) { if (command.Id == Guid.Empty) { return(new CommandResult(false, "Informe o Id da sala")); } if (!_salaRepository.Existe(command.Id)) { return(new CommandResult(false, "Sala não encontrada")); } _salaRepository.Excluir(command.Id); return(await Task.FromResult(new CommandResult(true, "Sala excluida com sucesso"))); }
public async Task <CommandResult> Excluir(Guid id) { try { var command = new ExcluirSalaCommand { Id = id }; return(await _handler.Handle(command)); } catch (Exception ex) { return(await Task.FromResult(new CommandResult(false, ex.Message))); } }