Example #1
0
        public async Task <CommandResult> Handle(IncluirSalaCommand command, CancellationToken cancellationToken)
        {
            var sala = SalaFactory.Create(Guid.NewGuid(), command);

            _salaRepository.Incluir(sala);

            return(await Task.FromResult(new CommandResult(true, "Sala incluida com sucesso")));
        }
Example #2
0
        public async Task <CommandResult> Handle(EditarSalaCommand command, CancellationToken cancellationToken)
        {
            if (!_salaRepository.Existe(command.Id))
            {
                return(new CommandResult(false, "Sala não encontrada"));
            }

            var sala = SalaFactory.Create(command.Id, command);

            _salaRepository.Atualizar(sala);

            return(await Task.FromResult(new CommandResult(true, "Sala editada com sucesso")));
        }