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