You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Server-Panel/Services/HttpTeamService.cs

34 lines
1.1 KiB

using System.Net.Http.Json;
using AdminPanel.Models;
namespace AdminPanel.Services;
public class HttpTeamService : ITeamService
{
private readonly HttpClient _client;
public HttpTeamService(HttpClient client)
{
this._client = client;
}
private record ListTeamResponse(uint TotalCount, List<Team> Teams);
public async Task<(uint, List<Team>)> ListTeam(uint from, uint count)
{
var httpResponse = await _client.GetAsync($"/api/admin/list-team?start={from}&n={count}");
httpResponse.EnsureSuccessStatusCode();
var response = await httpResponse.Content.ReadFromJsonAsync<ListTeamResponse>()!;
return (response.TotalCount, response.Teams);
}
private record AddTeamRequest(string Name, string Picture, string MainColor, string SecondaryColor);
public async Task AddTeam(string name, string Picture, string mainColor, string secondaryColor)
{
var httpResponse = await _client.PostAsJsonAsync($"/api/admin/add-team", new AddTeamRequest(name,Picture,mainColor,secondaryColor));
httpResponse.EnsureSuccessStatusCode();
}
}