public ICommandResult Handle(DeleteEndpointCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados inválidos. Verifique o preenchimento dos campos e tente novamente.", command.Notifications)); } var endpoint = _repository.GetBySerialNumber(command.SerialNumber); if (endpoint == null) { return(new GenericCommandResult(false, "Nenhum Endpoint encontrado com esse Número Serial.", null)); } if (_repository.Delete(command.SerialNumber)) { return(new GenericCommandResult(true, "Registro excluído com sucesso.", endpoint)); } else { return(new GenericCommandResult(false, "Erro ao excluir registro.", endpoint)); } }
public DeleteEndpointHanlderTests() { _endpointRepository = new EndpointFakeRepository(); _endpointHandler = new EndpointHandler(_endpointRepository); _deleteEndpointCommand = new DeleteEndpointCommand("1"); }