54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System.Net.Http;
|
|
|
|
namespace Client.Controllers;
|
|
using System.Text.Json;
|
|
|
|
|
|
// https://stackoverflow.com/questions/60256300/swaggerui-5-0-0-ignoring-jsonproperty-name
|
|
|
|
public class WebserviceClient
|
|
{
|
|
private ServiceClient _serviceClient;
|
|
private string _jsonSerializer;
|
|
public WebserviceClient(ServiceClient serviceClient)
|
|
{
|
|
this._serviceClient = serviceClient;
|
|
}
|
|
|
|
public async Task<List<Game>> GetAllGames()
|
|
{
|
|
var response = (List<Game>) await this._serviceClient.GameAllAsync();
|
|
return response;
|
|
}
|
|
|
|
public async Task<Game> GetGame(int id)
|
|
{
|
|
var response = (Game) await this._serviceClient.GameGETAsync(id);
|
|
return response;
|
|
}
|
|
|
|
public async Task<string> AddGame(Game game)
|
|
{
|
|
_jsonSerializer = JsonSerializer.Serialize(game);
|
|
|
|
// Wie kriege ich die Message hier rein
|
|
await _serviceClient.GamePOSTAsync(_jsonSerializer);
|
|
return "response AddGame";
|
|
}
|
|
|
|
public async Task<string> EditGame(int id, Game game)
|
|
{
|
|
_jsonSerializer = JsonSerializer.Serialize(game);
|
|
|
|
// Wie kriege ich die Message hier rein
|
|
await _serviceClient.GamePUTAsync(id, _jsonSerializer);
|
|
return "response EditGame";
|
|
}
|
|
|
|
public async Task<string> DeleteGame(int id)
|
|
{
|
|
// Wie kriege ich die Message hier rein
|
|
await _serviceClient.GameDELETEAsync(id);
|
|
return "response DeleteGame";
|
|
}
|
|
} |