Current items can be deleted by passing the UUID to the deleteItemFromServer signal.
This commit is contained in:
@ -77,3 +77,22 @@ void ServerCommunicator::postItems(const QByteArray& jsonData) {
|
||||
reply->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void ServerCommunicator::deleteItem(const QString& id) {
|
||||
const QString deleteRoute = QString("%1/%2").arg(ROUTE_ITEMS, id);
|
||||
QNetworkReply* reply = m_restManager->deleteResource(m_serviceApi->createRequest(deleteRoute));
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, [=]() {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
QByteArray responseData = reply->readAll();
|
||||
const QString message = QString("DELETE successful! Response: %1").arg(responseData);
|
||||
qInfo() << message;
|
||||
emit deleteRequestSuccessful(responseData);
|
||||
} else {
|
||||
const QString message = QString("Error: %1").arg(reply->errorString());
|
||||
qDebug() << message;
|
||||
emit deleteRequestFailure(message);
|
||||
}
|
||||
reply->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user