From 28e5a0e5709248057f321be0cc95a5b863e37e52 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 26 Mar 2023 20:20:21 +0200
Subject: [PATCH] correction du count, desormais fonctionnel en ligne de
commande
---
Sources/ConsoleApplication/Utils.cs | 3 ++-
Sources/HttpClient/ChampionCountResponse.cs | 23 +++++++++++++++++++
.../HttpClient/HttpClientManager.Champion.cs | 11 ++++++---
3 files changed, 33 insertions(+), 4 deletions(-)
create mode 100644 Sources/HttpClient/ChampionCountResponse.cs
diff --git a/Sources/ConsoleApplication/Utils.cs b/Sources/ConsoleApplication/Utils.cs
index fec49ea..6d9e315 100644
--- a/Sources/ConsoleApplication/Utils.cs
+++ b/Sources/ConsoleApplication/Utils.cs
@@ -36,7 +36,8 @@ namespace ConsoleApplication
switch (choix)
{
case "1":
- Console.WriteLine("# result : "+ await championsManager.GetNbItems());
+ var json = await championsManager.GetNbItems();
+ Console.WriteLine("# result : "+ json);
break;
case "2":
var list = await championsManager.GetItems(0, 10);
diff --git a/Sources/HttpClient/ChampionCountResponse.cs b/Sources/HttpClient/ChampionCountResponse.cs
new file mode 100644
index 0000000..7f523e9
--- /dev/null
+++ b/Sources/HttpClient/ChampionCountResponse.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HttpClient
+{
+ public class ChampionCountResponse
+ {
+ public int Result { get; set; }
+ public int Id { get; set; }
+ public object Exception { get; set; }
+ public int Status { get; set; }
+ public bool IsCanceled { get; set; }
+ public bool IsCompleted { get; set; }
+ public bool IsCompletedSuccessfully { get; set; }
+ public int CreationOptions { get; set; }
+ public object AsyncState { get; set; }
+ public bool IsFaulted { get; set; }
+ }
+
+}
diff --git a/Sources/HttpClient/HttpClientManager.Champion.cs b/Sources/HttpClient/HttpClientManager.Champion.cs
index 5eed5c0..672931c 100644
--- a/Sources/HttpClient/HttpClientManager.Champion.cs
+++ b/Sources/HttpClient/HttpClientManager.Champion.cs
@@ -74,9 +74,14 @@ namespace HttpClient
return httpc.GetFromJsonAsync>("v1/Champions?name=" + substring+"&index=" + index + "&size=" + count);
}
- public Task GetNbItems()
- {
- return httpc.GetFromJsonAsync("v1/Champions/count");
+ public async Task GetNbItems()
+ {
+ //HttpResponseMessage response =
+ //Console.WriteLine(response.Content.ToString());
+ //return int.Parse(response.Content.ToString());
+ //return await httpc.GetFromJsonAsync("v1/Champions/count");
+ var response = await httpc.GetFromJsonAsync("v1/Champions/count");
+ return response.Result;
}