Creation du client console
continuous-integration/drone/push Build is passing Details

ConsoleClient
Corentin R 2 years ago
parent 1a753c2926
commit 0720e06c14

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\HttpClient\HttpClient.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -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<LoLDBContextWithStub>();
var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var context = scope.ServiceProvider.GetService<LoLDBContextWithStub>();
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;
}
}
}

@ -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;
}
}
}
}
}
Loading…
Cancel
Save