Add project files.

This commit is contained in:
2024-04-22 16:48:36 +02:00
parent 35c4a91ec6
commit 086cb833f6
45 changed files with 1330 additions and 0 deletions

View File

@ -0,0 +1,32 @@
using System.Net.Http.Json;
namespace MonkeyFinder.Services;
public class MonkeyService
{
HttpClient httpClient;
public MonkeyService()
{
httpClient = new HttpClient();
}
List<Monkey> monkeyList = new();
public async Task<List<Monkey>> GetMonkeys()
{
if (monkeyList?.Count > 0)
{
return monkeyList;
}
var url = "https://montemagno.com/monkeys.json";
var response = await httpClient.GetAsync(url);
if(response.IsSuccessStatusCode)
{
monkeyList = await response.Content.ReadFromJsonAsync<List<Monkey>>();
}
return monkeyList;
}
}