public ICommandResult Handle(ActivateResidentCommand command) { // Fail Fast Validation command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Ops, erro ao ativar morador.", command.Notifications)); } // Hidrata morador var resident = _repository.GetById(command.Id, command.User); if (resident == null) { return(new GenericCommandResult(false, "Ops, erro ao ativar morador.", command.Id)); } resident.Activate(); try { // Atualiza morador _repository.Update(resident); } catch (Exception ex) { return(new GenericCommandResult(false, "Erro inesperado!", ex.Message)); } return(new GenericCommandResult(true, "Morador ativado com sucesso!", null)); }
public ActivateResidentTests() { _validCommand.Validate(); _invalidCommand.Validate(); }