27 lines
633 B
C#
27 lines
633 B
C#
using System.Net.Http;
|
|
using System.Net.Http.Json;
|
|
using System.Threading.Tasks;
|
|
using antblazorpro.Models;
|
|
|
|
namespace antblazorpro.Services
|
|
{
|
|
public interface IUserService
|
|
{
|
|
Task<CurrentUser> GetCurrentUserAsync();
|
|
}
|
|
|
|
public class UserService : IUserService
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
|
|
public UserService(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
public async Task<CurrentUser> GetCurrentUserAsync()
|
|
{
|
|
return await _httpClient.GetFromJsonAsync<CurrentUser>("data/current_user.json");
|
|
}
|
|
}
|
|
} |