Remove game from library and server

This commit is contained in:
Aurélie Delhaie
2022-07-20 19:57:40 +02:00
parent 5d96a98b5e
commit 37a8b48330
17 changed files with 164 additions and 58 deletions

View File

@@ -708,6 +708,35 @@ namespace OpenSaveCloudClient.Core
return false;
}
public bool DeleteGame(long gameId)
{
logManager.AddInformation("Delete a game from the server");
string uuidTask = taskManager.StartTask("Deleting game", true, 1);
try
{
using HttpClient client = new();
client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
HttpResponseMessage response = client.DeleteAsync(string.Format("{0}:{1}/api/v1/game/remove/{2}", host, port, gameId)).Result;
if (response.IsSuccessStatusCode)
{
string responseText = response.Content.ReadAsStringAsync().Result;
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Ended);
return true;
}
else
{
LogServerError(response);
}
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
}
catch (Exception ex)
{
logManager.AddError(ex);
taskManager.UpdateTaskStatus(uuidTask, AsyncTaskStatus.Failed);
}
return false;
}
public bool ChangePassword(NewPassword password)
{
logManager.AddInformation("Changing password");