Добавил поиск

This commit is contained in:
serega404 committed 2023-07-29 22:57:32 +03:00
1 parent 2d31231c2e
commit 202ba42bb5
8 files changed
+55 -15

No files matched your search

@@ -0,0 +1,31 @@
using System.Text.Json;
using PaydayFrontend.Models;
namespace PaydayFrontend.Services;
public interface IUniversityService
{
public Task<List<University>> GetAllUniversity();
}
public class UniversityService : IUniversityService
{
private readonly HttpClient _httpClient;
public UniversityService(HttpClient httpClient)
{
_httpClient = httpClient;
_httpClient.BaseAddress = new Uri("https://payday.zetcraft.ru");
}
public async Task<List<University>> GetAllUniversity()
{
var response = await _httpClient.GetAsync("v1/public/university");
var result = await response.Content.ReadAsStringAsync();
var university = JsonSerializer.Deserialize<List<University>>(result, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return university;
}
}