From 0720e06c14e20cf5e16f0a83746670417f673787 Mon Sep 17 00:00:00 2001
From: Corentin R <76619184+Koroh63@users.noreply.github.com>
Date: Sun, 26 Mar 2023 16:43:45 +0200
Subject: [PATCH] Creation du client console
---
.../ConsoleApplication.csproj | 15 +++++
Sources/ConsoleApplication/Program.cs | 44 +++++++++++++++
Sources/ConsoleApplication/Utils.cs | 55 +++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 Sources/ConsoleApplication/ConsoleApplication.csproj
create mode 100644 Sources/ConsoleApplication/Program.cs
create mode 100644 Sources/ConsoleApplication/Utils.cs
diff --git a/Sources/ConsoleApplication/ConsoleApplication.csproj b/Sources/ConsoleApplication/ConsoleApplication.csproj
new file mode 100644
index 0000000..3e93ad0
--- /dev/null
+++ b/Sources/ConsoleApplication/ConsoleApplication.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/Sources/ConsoleApplication/Program.cs b/Sources/ConsoleApplication/Program.cs
new file mode 100644
index 0000000..d3916f1
--- /dev/null
+++ b/Sources/ConsoleApplication/Program.cs
@@ -0,0 +1,44 @@
+
+using ConsoleApplication;
+using EntityFramework;
+using HttpClient;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+using Model;
+
+var builder = WebApplication.CreateBuilder();
+
+builder.Services.AddDbContext();
+
+var app = builder.Build();
+
+using (var scope = app.Services.CreateScope())
+{
+ var context = scope.ServiceProvider.GetService();
+ context.Database.EnsureCreated();
+}
+
+IDataManager dataManager = new HttpClientManager();
+
+string choice = "0";
+
+while (choice != "9")
+{
+ Utils.showMainMenu();
+ choice = Console.ReadLine();
+
+ switch (choice)
+ {
+ case "1":
+ {
+ Utils.championMenu(dataManager.ChampionsMgr);
+ break;
+ }
+ case "2":
+ {
+ //Utils.
+ break;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Sources/ConsoleApplication/Utils.cs b/Sources/ConsoleApplication/Utils.cs
new file mode 100644
index 0000000..fb70443
--- /dev/null
+++ b/Sources/ConsoleApplication/Utils.cs
@@ -0,0 +1,55 @@
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApplication
+{
+ public static class Utils
+ {
+ public static void showMainMenu()
+ {
+ Console.WriteLine("-------- Menu -------");
+ Console.WriteLine(" 1 - Champions ");
+ Console.WriteLine(" 2 - Skills ");
+ Console.WriteLine("\n 9 - Quitter");
+ }
+
+ public static void showChampionMenu()
+ {
+ Console.WriteLine("-------- Champion -------");
+ Console.WriteLine(" 1 - Count ");
+ Console.WriteLine(" 2 - Default ");
+ Console.WriteLine("\n 9 - Quitter");
+ }
+
+ public static async void championMenu(IChampionsManager championsManager ) {
+ string choix = "0";
+
+ while (choix != "9")
+ {
+ Utils.showChampionMenu();
+ choix = Console.ReadLine();
+
+ switch (choix)
+ {
+ case "1":
+ //Console.WriteLine("# result : "+ await championsManager.GetNbItems());
+ break;
+ case "2":
+ var list = await championsManager.GetItems(0, 10);
+ foreach(var cham in list)
+ {
+ Console.WriteLine("# result : " +cham.ToString());
+
+ }
+ break;
+ }
+ }
+ }
+
+
+ }
+}