Add kunden login index

This commit is contained in:
MET18937 2023-06-24 17:11:52 +02:00
parent 7b8db08d99
commit a9418aea33

View File

@ -1,6 +1,8 @@
@page "/"
@layout Startseite
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
<PageTitle>Yummy4Friends</PageTitle>
@ -14,10 +16,43 @@
<button type="submit" id="button1" class="btn">QR-Code einscannen</button>
<input type="text" class="form-control" id="qrcode" placeholder="Zugangscode eintragen" name="qrcode">
<input type="text" class="form-control" id="qrcode" placeholder="Zugangscode eintragen" name="qrcode" @bind-value="@qrcodeValue">
<button type="submit" id="button1" class="btn">Bestätigen</button>
<button type="submit" id="button1" class="btn" @onclick="@(() => CheckCode())">Bestätigen</button>
</div>
</body>
@code {
private string qrcodeValue;
private List<Kunde> kunden = new List<Kunde>();
public void CheckCode()
{
foreach (var kunde in kunden)
{
if (kunde.Code == qrcodeValue)
{
localStorage.SetItem("kunde", kunde);
break;
}
}
}
protected override async Task OnInitializedAsync()
{
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
}
public class Kunde
{
public int Idkunde { get; set; }
public string Code { get; set; }
public int Treuepunkte { get; set; }
}
}