talkspace templates added
This commit is contained in:
73
Account_SQLite/Pages/Index.razor
Normal file
73
Account_SQLite/Pages/Index.razor
Normal file
@ -0,0 +1,73 @@
|
||||
@page "/"
|
||||
@using SqliteWasmHelper
|
||||
@using Account_SQLite.Data
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@inject ISqliteWasmDbContextFactory<AccountContext> Factory
|
||||
|
||||
<PageTitle>Account_SQLite</PageTitle>
|
||||
|
||||
<h1>Accounts</h1>
|
||||
<p>Type some account:</p>
|
||||
<input @bind="newAccount" disabled="@busy" />
|
||||
<button @onclick="@(async () => await AddAccountAsync())" disabled="@busy">Add</button>
|
||||
|
||||
@if (@busy)
|
||||
{
|
||||
<div class="alert alert-info">💾 Scanning a floppy disk...</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accounts.Length < 1)
|
||||
{
|
||||
<p>I see no-account.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul>
|
||||
@foreach (var account in accounts)
|
||||
{
|
||||
<li>@account.Name</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
|
||||
Download backup:
|
||||
<BackupLink @ref="bl" DbContextType="typeof(AccountContext)" />
|
||||
|
||||
@code {
|
||||
private bool busy;
|
||||
private BackupLink bl = null!;
|
||||
private string newAccount = string.Empty;
|
||||
private Account[] accounts = Array.Empty<Account>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await RefreshUiAsync();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private async Task RefreshUiAsync()
|
||||
{
|
||||
using var ctx = await Factory.CreateDbContextAsync();
|
||||
busy = true;
|
||||
accounts = await ctx.Accounts.ToArrayAsync();
|
||||
await bl.RefreshAsync();
|
||||
busy = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task AddAccountAsync()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(newAccount))
|
||||
{
|
||||
using var ctx = await Factory.CreateDbContextAsync();
|
||||
ctx.Accounts.Add(new Account { Name = newAccount });
|
||||
busy = true;
|
||||
await ctx.SaveChangesAsync();
|
||||
newAccount = string.Empty;
|
||||
busy = false;
|
||||
await RefreshUiAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Account_SQLite/Pages/_Host.cshtml
Normal file
8
Account_SQLite/Pages/_Host.cshtml
Normal file
@ -0,0 +1,8 @@
|
||||
@page "/"
|
||||
@namespace Account_SQLite.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
||||
<component type="typeof(App)" render-mode="ServerPrerendered" />
|
||||
32
Account_SQLite/Pages/_Layout.cshtml
Normal file
32
Account_SQLite/Pages/_Layout.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@namespace Account_SQLite.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<base href="~/" />
|
||||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
||||
<link href="css/site.css" rel="stylesheet" />
|
||||
<link href="Account_SQLite.styles.css" rel="stylesheet" />
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
<environment include="Staging,Production">
|
||||
An error has occurred. This application may no longer respond until reloaded.
|
||||
</environment>
|
||||
<environment include="Development">
|
||||
An unhandled exception has occurred. See browser dev tools for details.
|
||||
</environment>
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user