Check if user is logged in

If the user is not logged in they will be redireted to the login page
Removed old razor Page that is not needed anymore
This commit is contained in:
FUH22860 2023-06-24 18:42:11 +02:00
parent 7cd20602b6
commit c85415e740
Signed by: FUH22860
GPG Key ID: 883891A3D2A98580
5 changed files with 69 additions and 25 deletions

View File

@ -2,6 +2,7 @@
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager
<h1>Speisekarte Chinesisch</h1>
<div class="container">
@ -113,8 +114,23 @@
private List<Menuitemueberkategorie> menuitemueberkategories = new List<Menuitemueberkategorie>();
private List<Rabatt> rabatte = new List<Rabatt>();
private Kunde curretKunde = new Kunde();
protected override async Task OnInitializedAsync()
{
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
if (kunden.Count > 0)
{
var kunde = localStorage.GetItem<Kunde>("kunde");
if (kunde != null)
{
curretKunde = kunde;
}
else
{
_navigationManager.NavigateTo("/");
}
}
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
@ -122,7 +138,6 @@
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
menuitems = await Http.GetFromJsonAsync<List<Menuitem>>("https://localhost:7076/api/Menuitems");
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");

View File

@ -2,6 +2,7 @@
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager
<h1>Speisekarte Getränke</h1>
@* create an container bootstrap 5*@
@ -120,8 +121,24 @@
private List<Menuitemueberkategorie> menuitemueberkategories = new List<Menuitemueberkategorie>();
private List<Rabatt> rabatte = new List<Rabatt>();
private Kunde curretKunde = new Kunde();
protected override async Task OnInitializedAsync()
{
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
if (kunden.Count > 0)
{
var kunde = localStorage.GetItem<Kunde>("kunde");
if (kunde != null)
{
curretKunde = kunde;
}
else
{
_navigationManager.NavigateTo("/");
}
}
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
@ -129,7 +146,6 @@
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
menuitems = await Http.GetFromJsonAsync<List<Menuitem>>("https://localhost:7076/api/Menuitems");
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");

View File

@ -2,6 +2,7 @@
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager
<h1>Speisekarte Sonstiges</h1>
@* create an container bootstrap 5*@
@ -92,11 +93,6 @@
</div>
</div>
@code {
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
@ -123,15 +119,31 @@
private List<Menuitemueberkategorie> menuitemueberkategories = new List<Menuitemueberkategorie>();
private List<Rabatt> rabatte = new List<Rabatt>();
private Kunde curretKunde = new Kunde();
protected override async Task OnInitializedAsync()
{
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
if (kunden.Count > 0)
{
var kunde = localStorage.GetItem<Kunde>("kunde");
if (kunde != null)
{
curretKunde = kunde;
}
else
{
_navigationManager.NavigateTo("/");
}
}
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
menuitems = await Http.GetFromJsonAsync<List<Menuitem>>("https://localhost:7076/api/Menuitems");
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");

View File

@ -2,6 +2,7 @@
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager
<h1>Speisekarte Japanisch</h1>
@* create an container bootstrap 5*@
@ -117,15 +118,31 @@
private List<Menuitemueberkategorie> menuitemueberkategories = new List<Menuitemueberkategorie>();
private List<Rabatt> rabatte = new List<Rabatt>();
private Kunde curretKunde = new Kunde();
protected override async Task OnInitializedAsync()
{
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
if (kunden.Count > 0)
{
var kunde = localStorage.GetItem<Kunde>("kunde");
if (kunde != null)
{
curretKunde = kunde;
}
else
{
_navigationManager.NavigateTo("/");
}
}
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
menuitems = await Http.GetFromJsonAsync<List<Menuitem>>("https://localhost:7076/api/Menuitems");
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");

View File

@ -1,16 +0,0 @@
<div class="alert alert-secondary mt-4">
<span class="oi oi-pencil me-2" aria-hidden="true"></span>
<strong>@Title</strong>
<span class="text-nowrap">
Please take our
<a target="_blank" class="font-weight-bold link-dark" href="https://go.microsoft.com/fwlink/?linkid=2186157">brief survey</a>
</span>
and tell us what you think.
</div>
@code {
// Demonstrates how a parent component can supply parameters
[Parameter]
public string? Title { get; set; }
}