using Biskilog_Accounting.Shared.CustomModels;
using System.Net.Http.Json;
using System.Text.Json;
namespace Biskilog_Accounting.Client.Pages.Dashboard
{
public partial class Dashboard
{
private TradeSummary m_tradeSummary { get; set; } = new TradeSummary();
private string m_username { get; set; } = string.Empty;
protected override async Task OnInitializedAsync()
{
m_username = m_tokenService.GetUserNameFromToken(await m_tokenService.GetToken())!;
await GetSummary();
return;
}
///
/// Gets the tade summary
///
///
async Task GetSummary()
{
try
{
var response = await m_http.GetAsync("api/analytics/tradesummary");
if (response.IsSuccessStatusCode)
{
var jsonContent = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var tradeSummary = JsonSerializer.Deserialize(jsonContent, options);
m_tradeSummary = tradeSummary;
StateHasChanged();
}
}catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}