mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 14:40:36 +01:00
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Data;
|
|
using BTCPayServer.Services;
|
|
using BTCPayServer.Services.Stores;
|
|
using BTCPayServer.Services.Wallets;
|
|
using Dapper;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NBXplorer;
|
|
using NBXplorer.Client;
|
|
|
|
namespace BTCPayServer.Components.StoreWalletBalance;
|
|
|
|
public class StoreWalletBalance : ViewComponent
|
|
{
|
|
private string CryptoCode;
|
|
private const WalletHistogramType DefaultType = WalletHistogramType.Week;
|
|
|
|
private readonly StoreRepository _storeRepo;
|
|
private readonly WalletHistogramService _walletHistogramService;
|
|
|
|
public StoreWalletBalance(StoreRepository storeRepo, WalletHistogramService walletHistogramService, BTCPayNetworkProvider networkProvider)
|
|
{
|
|
_storeRepo = storeRepo;
|
|
_walletHistogramService = walletHistogramService;
|
|
CryptoCode = networkProvider.DefaultNetwork.CryptoCode;
|
|
}
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync(StoreData store)
|
|
{
|
|
var walletId = new WalletId(store.Id, CryptoCode);
|
|
var data = await _walletHistogramService.GetHistogram(store, walletId, DefaultType);
|
|
|
|
var vm = new StoreWalletBalanceViewModel
|
|
{
|
|
Store = store,
|
|
CryptoCode = CryptoCode,
|
|
WalletId = walletId,
|
|
Series = data?.Series,
|
|
Labels = data?.Labels,
|
|
Balance = data?.Balance,
|
|
Type = DefaultType
|
|
};
|
|
|
|
return View(vm);
|
|
}
|
|
}
|