From bbbefa43b47abc7051af48daee3e0aaf723c72da Mon Sep 17 00:00:00 2001 From: MET18937 <79221078+MET18937@users.noreply.github.com> Date: Sun, 25 Jun 2023 21:06:53 +0200 Subject: [PATCH] Add page acees only on valid kunde login --- src/y4f/Pages/Allergene.razor | 201 ++++++++++++--------- src/y4f/Pages/Cookies.razor | 28 +++ src/y4f/Pages/Datenschutzerklärung.razor | 28 +++ src/y4f/Pages/FetchData.razor | 57 ------ src/y4f/Pages/Index.razor | 56 +++++- src/y4f/Pages/Kontakt.razor | 32 ++++ src/y4f/Pages/ShoppingCart.razor | 16 +- src/y4f/Pages/Speisekarte.razor | 24 ++- src/y4f/Pages/SpeisekarteCnDetails.razor | 17 +- src/y4f/Pages/SpeisekarteDrDetails.razor | 16 +- src/y4f/Pages/SpeisekarteEtcDetails.razor | 15 +- src/y4f/Pages/SpeisekarteJpDetails.razor | 16 +- src/y4f/Pages/TestFetchAllergienData.razor | 51 ------ src/y4f/Pages/YummyPoints.razor | 32 ++++ src/y4f/Shared/Bestellabschluss.razor | 13 +- src/y4f/Shared/Bestellbestätigung.razor | 12 ++ src/y4f/Shared/Feedback/FBestätigung.razor | 37 +++- src/y4f/Shared/Feedback/Feedback.razor | 38 +++- src/y4f/Shared/Kontoverwaltung.razor | 28 ++- src/y4f/Shared/Yummy-Punkte.razor | 13 ++ 20 files changed, 507 insertions(+), 223 deletions(-) delete mode 100644 src/y4f/Pages/FetchData.razor delete mode 100644 src/y4f/Pages/TestFetchAllergienData.razor diff --git a/src/y4f/Pages/Allergene.razor b/src/y4f/Pages/Allergene.razor index e87bddf..5f9afa6 100644 --- a/src/y4f/Pages/Allergene.razor +++ b/src/y4f/Pages/Allergene.razor @@ -1,90 +1,125 @@ @page "/allergene" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + } + + public class Kunde + { + public int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +} + + Allergene - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Allergeninformation
gemäß Codex-Empfehlung
VisuellesKurzbezeichnungBuchstabencode
Getreideglutenhaltiges GetreideA
KrebstiereKrebstiereB
EiEiC
FischFischD
ErdnussErdnussE
SojaSojaF
Milch oder LaktoseMilch oder LaktoseG
SchalenfrüchteSchalenfrüchteH
SellerieSellerieL
SenfSenfM
SesamSesamN
SulfiteSulfiteO
LupinenLupinenP
WeichtiereWeichtiereR
Allergeninformation
gemäß Codex-Empfehlung
VisuellesKurzbezeichnungBuchstabencode
Getreideglutenhaltiges GetreideA
KrebstiereKrebstiereB
EiEiC
FischFischD
ErdnussErdnussE
SojaSojaF
Milch oder LaktoseMilch oder LaktoseG
SchalenfrüchteSchalenfrüchteH
SellerieSellerieL
SenfSenfM
SesamSesamN
SulfiteSulfiteO
LupinenLupinenP
WeichtiereWeichtiereR
-



\ No newline at end of file +
+
+
+
+ diff --git a/src/y4f/Pages/Cookies.razor b/src/y4f/Pages/Cookies.razor index 56a2862..0b39286 100644 --- a/src/y4f/Pages/Cookies.razor +++ b/src/y4f/Pages/Cookies.razor @@ -1,5 +1,33 @@ @page "/cookies" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + } + + public class Kunde + { + public int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +} diff --git a/src/y4f/Pages/Datenschutzerklärung.razor b/src/y4f/Pages/Datenschutzerklärung.razor index a0f1c31..d8ec827 100644 --- a/src/y4f/Pages/Datenschutzerklärung.razor +++ b/src/y4f/Pages/Datenschutzerklärung.razor @@ -1,5 +1,33 @@ @page "/datenschutzerklärung" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + } + + public class Kunde + { + public int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +} diff --git a/src/y4f/Pages/FetchData.razor b/src/y4f/Pages/FetchData.razor deleted file mode 100644 index 783a026..0000000 --- a/src/y4f/Pages/FetchData.razor +++ /dev/null @@ -1,57 +0,0 @@ -@page "/fetchdata" -@inject HttpClient Http - -Weather forecast - -

Weather forecast

- -

This component demonstrates fetching data from the server.

- -@if (forecasts == null) -{ -

Loading...

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { - forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); - } - - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public string? Summary { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - } -} diff --git a/src/y4f/Pages/Index.razor b/src/y4f/Pages/Index.razor index 7e4e883..6e8dc7e 100644 --- a/src/y4f/Pages/Index.razor +++ b/src/y4f/Pages/Index.razor @@ -1,20 +1,56 @@ - @page "/" - @layout Startseite +@page "/" +@layout Startseite +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager Yummy4Friends - -
-

Herzlich Willkommen!

- +
+

Herzlich Willkommen!

-
- -
-
+ + + + +
+@code { + private string qrcodeValue; + private List kunden = new List(); + + public void CheckCode() + { + foreach (var kunde in kunden) + { + if (kunde.Code == qrcodeValue) + { + localStorage.SetItem("kunde", kunde); + _navigationManager.NavigateTo("/speisekarte"); + break; + } + } + } + + protected override async Task OnInitializedAsync() + { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + } + + public class Kunde + { + public int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } + + +} + + + diff --git a/src/y4f/Pages/Kontakt.razor b/src/y4f/Pages/Kontakt.razor index 12cb0f7..d1a7013 100644 --- a/src/y4f/Pages/Kontakt.razor +++ b/src/y4f/Pages/Kontakt.razor @@ -1,5 +1,37 @@ @page "/Kontakt" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + } + + public class Kunde + { + public int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +} + + +

Kontakt

Kundenservice

diff --git a/src/y4f/Pages/ShoppingCart.razor b/src/y4f/Pages/ShoppingCart.razor index b2c912b..1c27340 100644 --- a/src/y4f/Pages/ShoppingCart.razor +++ b/src/y4f/Pages/ShoppingCart.razor @@ -122,6 +122,9 @@ @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + public int hour; public int minute; private void UpdateTime() @@ -182,7 +185,6 @@ // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt private List allergien = new List(); private List bestellungspositions = new List(); - private List kunden = new List(); private List menuitems = new List(); private List menuitemkategories = new List(); private List menuitemueberkategories = new List(); @@ -190,6 +192,17 @@ protected override async Task OnInitializedAsync() { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + + // get data from localstorage if (localStorage.GetItem>("MenuItemIds") != null) { @@ -199,7 +212,6 @@ // get data from api allergien = await Http.GetFromJsonAsync>("https://localhost:7076/api/allergien"); bestellungspositions = await Http.GetFromJsonAsync>("https://localhost:7076/api/bestellungspositionen"); - kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); menuitems = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitems"); menuitemkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitemkategories"); menuitemueberkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitemueberkategories"); diff --git a/src/y4f/Pages/Speisekarte.razor b/src/y4f/Pages/Speisekarte.razor index b61de9f..224ce41 100644 --- a/src/y4f/Pages/Speisekarte.razor +++ b/src/y4f/Pages/Speisekarte.razor @@ -1,6 +1,9 @@ @page "/Speisekarte" @inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager +

Speisekarte

@@ -70,11 +73,24 @@ @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + private List menuitemkategories = new List(); private List menuitemueberkategories = new List(); protected override async Task OnInitializedAsync() { + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + menuitemkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/MenuItemKategories"); menuitemueberkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/MenuItemUeberkategories"); } @@ -97,4 +113,10 @@ } -} \ No newline at end of file + public class Kunde + { + public int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +} diff --git a/src/y4f/Pages/SpeisekarteCnDetails.razor b/src/y4f/Pages/SpeisekarteCnDetails.razor index 7666c33..3d28962 100644 --- a/src/y4f/Pages/SpeisekarteCnDetails.razor +++ b/src/y4f/Pages/SpeisekarteCnDetails.razor @@ -2,6 +2,7 @@ @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager

Speisekarte Chinesisch

@@ -89,6 +90,9 @@ @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + public Dictionary menuitemIds = new Dictionary(); private void SetMenuItemId(int id) @@ -107,7 +111,6 @@ private List allergien = new List(); private List bestellungspositions = new List(); - private List kunden = new List(); private List menuitems = new List(); private List menuitemkategories = new List(); private List menuitemueberkategories = new List(); @@ -115,6 +118,18 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + if (localStorage.GetItem>("MenuItemIds") != null) { menuitemIds = localStorage.GetItem>("MenuItemIds"); diff --git a/src/y4f/Pages/SpeisekarteDrDetails.razor b/src/y4f/Pages/SpeisekarteDrDetails.razor index 155512d..6fe3edc 100644 --- a/src/y4f/Pages/SpeisekarteDrDetails.razor +++ b/src/y4f/Pages/SpeisekarteDrDetails.razor @@ -2,6 +2,7 @@ @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager

Speisekarte Getränke

@* create an container bootstrap 5*@ @@ -93,6 +94,8 @@ @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); public Dictionary menuitemIds = new Dictionary(); @@ -114,7 +117,6 @@ private List allergien = new List(); private List bestellungspositions = new List(); - private List kunden = new List(); private List menuitems = new List(); private List menuitemkategories = new List(); private List menuitemueberkategories = new List(); @@ -122,6 +124,18 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + if (localStorage.GetItem>("MenuItemIds") != null) { menuitemIds = localStorage.GetItem>("MenuItemIds"); diff --git a/src/y4f/Pages/SpeisekarteEtcDetails.razor b/src/y4f/Pages/SpeisekarteEtcDetails.razor index 20db45a..602fde5 100644 --- a/src/y4f/Pages/SpeisekarteEtcDetails.razor +++ b/src/y4f/Pages/SpeisekarteEtcDetails.razor @@ -2,6 +2,7 @@ @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager

Speisekarte Sonstiges

@* create an container bootstrap 5*@ @@ -98,6 +99,8 @@ @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); public Dictionary menuitemIds = new Dictionary(); @@ -117,7 +120,6 @@ private List allergien = new List(); private List bestellungspositions = new List(); - private List kunden = new List(); private List menuitems = new List(); private List menuitemkategories = new List(); private List menuitemueberkategories = new List(); @@ -125,6 +127,17 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end if (localStorage.GetItem>("MenuItemIds") != null) { menuitemIds = localStorage.GetItem>("MenuItemIds"); diff --git a/src/y4f/Pages/SpeisekarteJpDetails.razor b/src/y4f/Pages/SpeisekarteJpDetails.razor index 61b4777..c213acf 100644 --- a/src/y4f/Pages/SpeisekarteJpDetails.razor +++ b/src/y4f/Pages/SpeisekarteJpDetails.razor @@ -2,6 +2,7 @@ @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager

Speisekarte Japanisch

@* create an container bootstrap 5*@ @@ -92,6 +93,8 @@ @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); public Dictionary menuitemIds = new Dictionary(); @@ -111,7 +114,6 @@ private List allergien = new List(); private List bestellungspositions = new List(); - private List kunden = new List(); private List menuitems = new List(); private List menuitemkategories = new List(); private List menuitemueberkategories = new List(); @@ -119,6 +121,18 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + if (localStorage.GetItem>("MenuItemIds") != null) { menuitemIds = localStorage.GetItem>("MenuItemIds"); diff --git a/src/y4f/Pages/TestFetchAllergienData.razor b/src/y4f/Pages/TestFetchAllergienData.razor deleted file mode 100644 index 05de358..0000000 --- a/src/y4f/Pages/TestFetchAllergienData.razor +++ /dev/null @@ -1,51 +0,0 @@ -@page "/TestFetchAllergienData" - -@inject HttpClient Http - - -Allergien - -

Allergien

- -

This component demonstrates fetching data from the mysql server.

- -@if (allergien == null) -{ -

Loading...

-} -else -{ - - - - - - - - - @foreach (var allergie in allergien) - { - - - - - } - -
IDBeschreibung
@allergie.Idallergie@allergie.Beschreibung
-} -@code { - private const string ServiceEndpoint = "https://localhost:7076/api/Allergien"; - private Allergie[]? allergien; - - protected override async Task OnInitializedAsync() - { - allergien = await Http.GetFromJsonAsync(ServiceEndpoint); - } - - public partial class Allergie - { - public int Idallergie { get; set; } - - public string? Beschreibung { get; set; } - } -} diff --git a/src/y4f/Pages/YummyPoints.razor b/src/y4f/Pages/YummyPoints.razor index 411a99d..685e56d 100644 --- a/src/y4f/Pages/YummyPoints.razor +++ b/src/y4f/Pages/YummyPoints.razor @@ -1,5 +1,37 @@ @page "/yummypoints" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + + } + + public class Kunde + { + int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +}
diff --git a/src/y4f/Shared/Bestellabschluss.razor b/src/y4f/Shared/Bestellabschluss.razor index 930ab62..ba08311 100644 --- a/src/y4f/Shared/Bestellabschluss.razor +++ b/src/y4f/Shared/Bestellabschluss.razor @@ -158,10 +158,21 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + // get data from api allergien = await Http.GetFromJsonAsync>("https://localhost:7076/api/allergien"); bestellungspositions = await Http.GetFromJsonAsync>("https://localhost:7076/api/bestellungspositionen"); - kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); menuitems = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitems"); menuitemkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitemkategories"); menuitemueberkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitemueberkategories"); diff --git a/src/y4f/Shared/Bestellbestätigung.razor b/src/y4f/Shared/Bestellbestätigung.razor index 9e09351..b36aaf3 100644 --- a/src/y4f/Shared/Bestellbestätigung.razor +++ b/src/y4f/Shared/Bestellbestätigung.razor @@ -75,6 +75,18 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + // get data from api allergien = await Http.GetFromJsonAsync>("https://localhost:7076/api/allergien"); bestellungspositions = await Http.GetFromJsonAsync>("https://localhost:7076/api/bestellungspositionen"); diff --git a/src/y4f/Shared/Feedback/FBestätigung.razor b/src/y4f/Shared/Feedback/FBestätigung.razor index 8496c50..0ec9f53 100644 --- a/src/y4f/Shared/Feedback/FBestätigung.razor +++ b/src/y4f/Shared/Feedback/FBestätigung.razor @@ -1,5 +1,36 @@ @page "/FBestätigung" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + } + + public class Kunde + { + int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +}

Vielen Dank für Ihr Feedback. Durch Feedbacks können wir uns stets verbessern.

@@ -7,9 +38,3 @@
- - - -@code { - -} diff --git a/src/y4f/Shared/Feedback/Feedback.razor b/src/y4f/Shared/Feedback/Feedback.razor index 05757ff..ff54861 100644 --- a/src/y4f/Shared/Feedback/Feedback.razor +++ b/src/y4f/Shared/Feedback/Feedback.razor @@ -1,5 +1,37 @@ @page "/Feedback" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + protected override async Task OnInitializedAsync() + { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + } + + public class Kunde + { + int Idkunde { get; set; } + public string Code { get; set; } + public int Treuepunkte { get; set; } + } +} +

Ihr Feedback:

@@ -14,8 +46,4 @@
- -@code { - - -} + \ No newline at end of file diff --git a/src/y4f/Shared/Kontoverwaltung.razor b/src/y4f/Shared/Kontoverwaltung.razor index d6034e0..6d0d0b9 100644 --- a/src/y4f/Shared/Kontoverwaltung.razor +++ b/src/y4f/Shared/Kontoverwaltung.razor @@ -8,6 +8,10 @@
+@*log out Button *@ +
+ +

AccountID: @kunde.Code

@@ -125,8 +129,10 @@ - @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + bool changeButtonBool { get; set; } = true; string button1 => changeButtonBool ? "Konto deaktivieren" : "Konto aktivieren"; @@ -137,6 +143,12 @@ changeButtonBool = !changeButtonBool; } + public void Logout() + { + localStorage.Clear(); + _navigationManager.NavigateTo("/"); + } + public int hour; public int minute; public int day; @@ -153,14 +165,24 @@ private List bestellungspositions = new List(); - private List kunden = new List(); - private Kunde kunde = new Kunde(); private List menuitems = new List(); private List rabatte = new List(); private List bestellungspositionHasMenuitems = new List(); protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + // get data from api bestellungspositions = await Http.GetFromJsonAsync>("https://localhost:7076/api/bestellungspositionen"); kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); diff --git a/src/y4f/Shared/Yummy-Punkte.razor b/src/y4f/Shared/Yummy-Punkte.razor index b48af58..87b8396 100644 --- a/src/y4f/Shared/Yummy-Punkte.razor +++ b/src/y4f/Shared/Yummy-Punkte.razor @@ -1,6 +1,7 @@ @page "/Yummy-Punkte" @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager
@@ -59,6 +60,18 @@ protected override async Task OnInitializedAsync() { + // kunde login start + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + + if (localStorage.ContainKey("kunde")) + kunde = localStorage.GetItem("kunde"); + else + _navigationManager.NavigateTo("/"); + + if (kunde != null && !kunden.Any(k => k.Code == kunde.Code)) + _navigationManager.NavigateTo("/"); + // kunde login end + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); rabatte = await Http.GetFromJsonAsync>("https://localhost:7076/api/Rabatte");