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.
59 lines
1.9 KiB
59 lines
1.9 KiB
using Blazored.LocalStorage;
|
|
using Blazorise;
|
|
using Blazorise.DataGrid;
|
|
using HeartTrack.Models;
|
|
using HeartTrack.Services.TicketDataService;
|
|
using HeartTrack.Services.UserDataService;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Localization;
|
|
using static MudBlazor.CategoryTypes;
|
|
using System.Net.Http;
|
|
|
|
namespace HeartTrack.Pages
|
|
{
|
|
public partial class BannedUsers
|
|
{
|
|
private List<User> users;
|
|
|
|
private int totalUser;
|
|
|
|
[Inject]
|
|
public HttpClient Http { get; set; }
|
|
|
|
[Inject]
|
|
public NavigationManager NavigationManager { get; set; }
|
|
[Inject]
|
|
public ILocalStorageService LocalStorage { get; set; }
|
|
[Inject]
|
|
public IUserDataService UserService { get; set; }
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<User> e)
|
|
{
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// When you use a real API, we use this follow code
|
|
//var response = await Http.GetJsonAsync<Item[]>( $"http://my-api/api/data?page={e.Page}&pageSize={e.PageSize}" );
|
|
var response = (await Http.GetFromJsonAsync<User[]>($"{NavigationManager.BaseUri}fake-users.json")).Skip((e.Page - 1) * e.PageSize).Take(e.PageSize).ToList();
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
{
|
|
totalUser = (await Http.GetFromJsonAsync<List<User>>($"{NavigationManager.BaseUri}fake-users.json")).Count;
|
|
users = new List<User>(response); // an actual data for the current page
|
|
}
|
|
}
|
|
private void BanOnID(int id)
|
|
{
|
|
UserService.BanOnId(id);
|
|
NavigationManager.NavigateTo("/banned-users", true);
|
|
}
|
|
private void UnbanOnID(int id)
|
|
{
|
|
UserService.UnbanOnId(id);
|
|
NavigationManager.NavigateTo("/banned-users", true);
|
|
}
|
|
}
|
|
}
|