1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- @page "/account"
- @using HyperCube.Models;
- @using Microsoft.AspNetCore.Identity;
- @inject AuthenticationStateProvider AuthenticationStateProvider
- @inject UserManager<IdentityUser> UserManager;
- @attribute [Authorize]
- <h3>Личный кабинет</h3>
- <EditForm Model="@account">
- <table class="table-bordered" cellspacing="5" cellpadding="5">
- <tbody>
- <tr>
- <td>UUID:</td>
- <td>@account.UUID</td>
- </tr>
- <tr>
- <td>Name:</td>
- <td>@account.Name</td>
- </tr>
- <tr>
- <td>Email:</td>
- <td>@account.Email</td>
- </tr>
- <tr>
- <td>ETH Address:</td>
- <td>@account.eth_address</td>
- </tr>
- <tr>
- <td>Balance:</td>
- <td>@myBalance WEI</td>
- </tr>
- <tr>
- <td>Администратор:<input @bind="radio" type="checkbox" name="имя1" атрибуты></td>
- @radio
- </tr>
- <tr>
- <td>Инициатор:<input type="checkbox" name="имя2" атрибуты></td>
- </tr>
- <tr>
- <td>Верификатор:<input type="checkbox" name="имя3" атрибуты></td>
- </tr>
- <tr>
- <td>Заказчик:<input type="checkbox" name="имя4" атрибуты></td>
- </tr>
- </tbody>
- </table>
- </EditForm>
- @code {
- private AccountModel account = new();
- string myBalance = "";
- string radio;
- protected override async Task OnInitializedAsync()
- {
- account = await GetCurrentAcc();
- if (Blockchain.GetMain() != null)
- myBalance = await account.GetBalance();
- }
- private async Task<AccountModel> GetCurrentAcc()
- {
- AccountModel account = new();
- var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
- var user = authState.User;
- if (user.Identity.IsAuthenticated)
- {
- var currentUser = await UserManager.GetUserAsync(user);
- var acc = AccountModel.Find(currentUser.Id);
- if (acc != null)
- account = acc;
- account.AccRole = Role.User;
- return account;
- }
- return null;
- }
- }
|