From 31a82177d56c4fc7247b679f8018ea871ffc5589 Mon Sep 17 00:00:00 2001 From: MET18937 <79221078+MET18937@users.noreply.github.com> Date: Mon, 26 Jun 2023 09:41:13 +0200 Subject: [PATCH] Add admin login --- src/WebApi/Data/WebApiContext.cs | 4 +- src/y4f/Pages/Index.razor | 11 +- src/y4f/Shared/Bestellabschluss.razor | 15 +- src/y4f/Shared/Bestellbestätigung.razor | 1 - .../Chefin/Bestelluebersicht-Chefin.razor | 18 ++- .../Chefin/BestelluebersichtD-Chefin.razor | 15 +- src/y4f/Shared/Kontoverwaltung.razor | 3 +- src/y4f/Shared/NavMenu.razor | 140 +++++++++++------- src/y4f/Shared/RegistrierungA.razor | 84 ++++++++--- 9 files changed, 202 insertions(+), 89 deletions(-) diff --git a/src/WebApi/Data/WebApiContext.cs b/src/WebApi/Data/WebApiContext.cs index 7956dbc..68dfe82 100644 --- a/src/WebApi/Data/WebApiContext.cs +++ b/src/WebApi/Data/WebApiContext.cs @@ -221,8 +221,8 @@ public partial class WebApiContext : DbContext entity.ToTable("bestellungsposition_has_menuitem"); - entity.Property(e => e.Bestellungsposition_IDBestellung).HasColumnType("int(11)").HasColumnName("Bestellungsposition_IDBestellung"); - entity.Property(e => e.MenuItem_IDMenuItem).HasColumnType("int(11)").HasColumnName("MenuItem_IDMenuItem"); + entity.Property(e => e.Bestellungsposition_IDBestellung).HasColumnType("int(11)").HasColumnName("bestellungsposition_IDBestellung"); + entity.Property(e => e.MenuItem_IDMenuItem).HasColumnType("int(11)").HasColumnName("menuItem_IDMenuItem"); }); modelBuilder.Entity(entity => diff --git a/src/y4f/Pages/Index.razor b/src/y4f/Pages/Index.razor index 6e8dc7e..5210136 100644 --- a/src/y4f/Pages/Index.razor +++ b/src/y4f/Pages/Index.razor @@ -4,6 +4,7 @@ @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage @inject NavigationManager _navigationManager +@inject IJSRuntime JSRuntime; Yummy4Friends @@ -32,14 +33,22 @@ { localStorage.SetItem("kunde", kunde); _navigationManager.NavigateTo("/speisekarte"); - break; + return; } } + JSRuntime.InvokeVoidAsync("alert", "Zugangscode ist falsch!"); } protected override async Task OnInitializedAsync() { kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + // if already logged in navigate to speisekarte + if (localStorage.ContainKey("kunde")) + { + _navigationManager.NavigateTo("/speisekarte"); + } + + } public class Kunde diff --git a/src/y4f/Shared/Bestellabschluss.razor b/src/y4f/Shared/Bestellabschluss.razor index 9fa480e..1561944 100644 --- a/src/y4f/Shared/Bestellabschluss.razor +++ b/src/y4f/Shared/Bestellabschluss.razor @@ -89,6 +89,13 @@ { localStorage.SetItem("RabattEinloesen", false); localStorage.SetItem("Summe", summe); + // if summe > 8€ add treuepunkte + if (summe >= 8) + { + kunde.Treuepunkte++; + // add treuepunkte to API + Http.PutAsJsonAsync("https://localhost:7076/api/kunden/" + kunde.Idkunde, kunde); + } } // add bestellung to API @@ -108,6 +115,7 @@ } } } + foreach (var item in menuitemIds) { bestellungspositionId++; @@ -138,10 +146,9 @@ Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionhasmenuitems", bestellungspositionHasMenuItem); } + // delete all localStorage localStorage.SetItem("MenuItemIds", new Dictionary()); - //localStorage.SetItem("Hour", 0); - //localStorage.SetItem("Minute", 0); localStorage.SetItem("Summe", 0); localStorage.SetItem("RabattEinloesen", false); @@ -319,7 +326,7 @@ public class BestellungspositionHasMenuitem { - public int? Bestellungsposition_IDBestellung { get; set; } - public int? MenuItem_IDMenuItem { get; set; } + public int Bestellungsposition_IDBestellung { get; set; } + public int MenuItem_IDMenuItem { get; set; } } } \ No newline at end of file diff --git a/src/y4f/Shared/Bestellbestätigung.razor b/src/y4f/Shared/Bestellbestätigung.razor index 7253e2c..a670d08 100644 --- a/src/y4f/Shared/Bestellbestätigung.razor +++ b/src/y4f/Shared/Bestellbestätigung.razor @@ -96,7 +96,6 @@ menuitemueberkategories = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitemueberkategories"); rabatte = await Http.GetFromJsonAsync>("https://localhost:7076/api/Rabatte"); - // test use the first kunde // get kunde from local storage kunde = localStorage.GetItem("kunde"); diff --git a/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor b/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor index 4e31041..4dc990c 100644 --- a/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor +++ b/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor @@ -4,14 +4,19 @@ @inject HttpClient Http @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage @inject NavigationManager _navigationManager + +@*// logout button*@ +
+ +
-
+


- + @@ -59,7 +64,7 @@
Aktive Bestellungen @day.@month.@yearAktive Bestellungen @day.@month.@year
- @*
+

Abholzeit


@@ -72,7 +77,7 @@
-
*@ +
@@ -90,6 +95,11 @@ private Kunde kunde = new Kunde(); + public void Logout() + { + localStorage.Clear(); + _navigationManager.NavigateTo("/"); + } public void BDetail(int id) { localStorage.SetItem("KundeId", id); diff --git a/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor b/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor index 3d9e50b..8868574 100644 --- a/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor +++ b/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor @@ -5,8 +5,15 @@ @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage @inject NavigationManager _navigationManager + +@*// logout button*@ +
+ +
+
+
@*Tabelle Ihre Bestellung*@
@@ -69,7 +76,7 @@
- +
@@ -113,6 +120,7 @@ *@ + @code { public int hour; @@ -137,6 +145,11 @@ private List rabatte = new List(); private List bestellungspositionHasMenuitems = new List(); + public void Logout() + { + localStorage.Clear(); + _navigationManager.NavigateTo("/"); + } protected override async Task OnInitializedAsync() { // get data from api diff --git a/src/y4f/Shared/Kontoverwaltung.razor b/src/y4f/Shared/Kontoverwaltung.razor index df894fd..6c2ddc5 100644 --- a/src/y4f/Shared/Kontoverwaltung.razor +++ b/src/y4f/Shared/Kontoverwaltung.razor @@ -10,8 +10,9 @@ @*log out Button *@
- +
+

AccountID: @kunde.Code

diff --git a/src/y4f/Shared/NavMenu.razor b/src/y4f/Shared/NavMenu.razor index 5db4b0d..db990ca 100644 --- a/src/y4f/Shared/NavMenu.razor +++ b/src/y4f/Shared/NavMenu.razor @@ -1,61 +1,93 @@ -