mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-29 14:28:09 +02:00
Change project to 3-Layer structure
This commit is contained in:
parent
2f900a5036
commit
2d67540e13
1365 changed files with 760 additions and 618 deletions
43
UI/Pages/Index.cshtml.cs
Normal file
43
UI/Pages/Index.cshtml.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using MTWireGuard.Application;
|
||||
using MTWireGuard.Application.Repositories;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace MTWireGuard.Pages
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IMikrotikRepository API;
|
||||
|
||||
public IndexModel(ILogger<IndexModel> logger, IMikrotikRepository mikrotik)
|
||||
{
|
||||
_logger = logger;
|
||||
API = mikrotik;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
var users = await API.GetUsersAsync();
|
||||
var servers = await API.GetServersAsync();
|
||||
var traffics = await API.GetServersTraffic();
|
||||
var wgTraffics = traffics.Where(s => s.Type == "wg");
|
||||
long up = 0;
|
||||
long down = 0;
|
||||
foreach (var item in wgTraffics)
|
||||
{
|
||||
up += item.UploadBytes;
|
||||
down += item.DownloadBytes;
|
||||
}
|
||||
ViewData["users"] = users;
|
||||
ViewData["servers"] = servers;
|
||||
ViewData["uptr"] = Helper.ConvertByteSize(up, 2);
|
||||
ViewData["downtr"] = Helper.ConvertByteSize(down, 2);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue