From 28327710f8a92e912958ebe521f3f9f60202f6f0 Mon Sep 17 00:00:00 2001 From: MET18937 <79221078+MET18937@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:55:12 +0200 Subject: [PATCH] Warenkorb bestellungsabschluss + Login (Kunde/Chefin) (#48) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add Bestellabschluss link * Add vorbestllungsdata into Table Bestellungsposition * Add vorbestllungsdata into Table BestellungspositionHasMenuitem * Add complete vorbestellungsfunktion * Add kontaktverwaltung Bestellübersicht * Update Bestelluebersicht BestelluebersichtD-Chefin * Update Bestelluebersicht * Fix kunde.Idkunde access * Add page acees only on valid kunde login * Add current kunde usage * Add admin login * Fix frontend speisekarte1 * Fix treuepunkte vergabe * Fix chefin bestellungseinsicht --- ...stellungspositionHasMenuitemsController.cs | 138 ++++++ src/WebApi/Data/WebApiContext.cs | 68 +-- src/WebApi/Models/Bestellungsposition.cs | 18 +- .../Models/BestellungspositionHasMenuitem.cs | 11 + 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 | 65 ++- src/y4f/Pages/Kontakt.razor | 32 ++ src/y4f/Pages/ShoppingCart.razor | 58 ++- src/y4f/Pages/Speisekarte.razor | 51 ++- src/y4f/Pages/SpeisekarteCnDetails.razor | 19 +- src/y4f/Pages/SpeisekarteDrDetails.razor | 18 +- src/y4f/Pages/SpeisekarteEtcDetails.razor | 17 +- src/y4f/Pages/SpeisekarteJpDetails.razor | 18 +- src/y4f/Pages/TestFetchAllergienData.razor | 51 --- src/y4f/Pages/YummyPoints.razor | 32 ++ src/y4f/Shared/Bestellabschluss.razor | 361 ++++++++++++++-- src/y4f/Shared/Bestellbestätigung.razor | 257 ++++++++++-- .../Chefin/Bestelluebersicht-Chefin.razor | 229 +++++++--- .../Chefin/BestelluebersichtD-Chefin.razor | 395 ++++++++++++------ src/y4f/Shared/Feedback/FBestätigung.razor | 37 +- src/y4f/Shared/Feedback/Feedback.razor | 38 +- src/y4f/Shared/Kontoverwaltung.razor | 304 +++++++++++++- src/y4f/Shared/NavMenu.razor | 140 ++++--- src/y4f/Shared/RegistrierungA.razor | 84 +++- src/y4f/Shared/Yummy-Punkte.razor | 16 +- 28 files changed, 2160 insertions(+), 611 deletions(-) create mode 100644 src/WebApi/Controllers/BestellungspositionHasMenuitemsController.cs create mode 100644 src/WebApi/Models/BestellungspositionHasMenuitem.cs delete mode 100644 src/y4f/Pages/FetchData.razor delete mode 100644 src/y4f/Pages/TestFetchAllergienData.razor diff --git a/src/WebApi/Controllers/BestellungspositionHasMenuitemsController.cs b/src/WebApi/Controllers/BestellungspositionHasMenuitemsController.cs new file mode 100644 index 0000000..de3011e --- /dev/null +++ b/src/WebApi/Controllers/BestellungspositionHasMenuitemsController.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using WebApi.Data; +using WebApi.Models; + +namespace WebApi.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class BestellungspositionHasMenuitemsController : ControllerBase + { + private readonly WebApiContext _context; + + public BestellungspositionHasMenuitemsController(WebApiContext context) + { + _context = context; + } + + // GET: api/BestellungspositionHasMenuitems + [HttpGet] + public async Task>> GetBestellungspositionHasMenuitem() + { + if (_context.BestellungspositionHasMenuitem == null) + { + return NotFound(); + } + return await _context.BestellungspositionHasMenuitem.ToListAsync(); + } + + // GET: api/BestellungspositionHasMenuitems/5 + [HttpGet("{id}")] + public async Task> GetBestellungspositionHasMenuitem(int? id) + { + if (_context.BestellungspositionHasMenuitem == null) + { + return NotFound(); + } + var bestellungspositionHasMenuitem = await _context.BestellungspositionHasMenuitem.FindAsync(id); + + if (bestellungspositionHasMenuitem == null) + { + return NotFound(); + } + + return bestellungspositionHasMenuitem; + } + + // PUT: api/BestellungspositionHasMenuitems/5 + // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 + [HttpPut("{id}")] + public async Task PutBestellungspositionHasMenuitem(int? id, BestellungspositionHasMenuitem bestellungspositionHasMenuitem) + { + if (id != bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung) + { + return BadRequest(); + } + + _context.Entry(bestellungspositionHasMenuitem).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!BestellungspositionHasMenuitemExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/BestellungspositionHasMenuitems + // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 + [HttpPost] + public async Task> PostBestellungspositionHasMenuitem(BestellungspositionHasMenuitem bestellungspositionHasMenuitem) + { + if (_context.BestellungspositionHasMenuitem == null) + { + return Problem("Entity set 'WebApiContext.BestellungspositionHasMenuitem' is null."); + } + _context.BestellungspositionHasMenuitem.Add(bestellungspositionHasMenuitem); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (BestellungspositionHasMenuitemExists(bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtAction("GetBestellungspositionHasMenuitem", new { id = bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung }, bestellungspositionHasMenuitem); + } + + // DELETE: api/BestellungspositionHasMenuitems/5 + [HttpDelete("{id}")] + public async Task DeleteBestellungspositionHasMenuitem(int? id) + { + if (_context.BestellungspositionHasMenuitem == null) + { + return NotFound(); + } + var bestellungspositionHasMenuitem = await _context.BestellungspositionHasMenuitem.FindAsync(id); + if (bestellungspositionHasMenuitem == null) + { + return NotFound(); + } + + _context.BestellungspositionHasMenuitem.Remove(bestellungspositionHasMenuitem); + await _context.SaveChangesAsync(); + + return NoContent(); + } + + private bool BestellungspositionHasMenuitemExists(int? id) + { + return (_context.BestellungspositionHasMenuitem?.Any(e => e.Bestellungsposition_IDBestellung == id)).GetValueOrDefault(); + } + } +} diff --git a/src/WebApi/Data/WebApiContext.cs b/src/WebApi/Data/WebApiContext.cs index c4f672f..7956dbc 100644 --- a/src/WebApi/Data/WebApiContext.cs +++ b/src/WebApi/Data/WebApiContext.cs @@ -29,6 +29,8 @@ public partial class WebApiContext : DbContext public virtual DbSet Admins { get; set; } + public virtual DbSet BestellungspositionHasMenuitem { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder @@ -81,31 +83,31 @@ public partial class WebApiContext : DbContext .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_Bestellungsposition_Rabatt1"); - entity.HasMany(d => d.MenuItemIdmenuItems).WithMany(p => p.BestellungspositionIdbestellungs) - .UsingEntity>( - "BestellungspositionHasMenuitem", - r => r.HasOne().WithMany() - .HasForeignKey("MenuItemIdmenuItem") - .OnDelete(DeleteBehavior.ClientSetNull) - .HasConstraintName("fk_Bestellungsposition_has_MenuItem_MenuItem1"), - l => l.HasOne().WithMany() - .HasForeignKey("BestellungspositionIdbestellung") - .OnDelete(DeleteBehavior.ClientSetNull) - .HasConstraintName("fk_Bestellungsposition_has_MenuItem_Bestellungsposition1"), - j => - { - j.HasKey("BestellungspositionIdbestellung", "MenuItemIdmenuItem") - .HasName("PRIMARY") - .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); - j.ToTable("bestellungsposition_has_menuitem"); - j.HasIndex(new[] { "MenuItemIdmenuItem" }, "fk_Bestellungsposition_has_MenuItem_MenuItem1"); - j.IndexerProperty("BestellungspositionIdbestellung") - .HasColumnType("int(11)") - .HasColumnName("Bestellungsposition_IDBestellung"); - j.IndexerProperty("MenuItemIdmenuItem") - .HasColumnType("int(11)") - .HasColumnName("MenuItem_IDMenuItem"); - }); + //entity.HasMany(d => d.MenuItemIdmenuItems).WithMany(p => p.BestellungspositionIdbestellungs) + // .UsingEntity>( + // "BestellungspositionHasMenuitem", + // r => r.HasOne().WithMany() + // .HasForeignKey("MenuItemIdmenuItem") + // .OnDelete(DeleteBehavior.ClientSetNull) + // .HasConstraintName("fk_Bestellungsposition_has_MenuItem_MenuItem1"), + // l => l.HasOne().WithMany() + // .HasForeignKey("BestellungspositionIdbestellung") + // .OnDelete(DeleteBehavior.ClientSetNull) + // .HasConstraintName("fk_Bestellungsposition_has_MenuItem_Bestellungsposition1"), + // j => + // { + // j.HasKey("BestellungspositionIdbestellung", "MenuItemIdmenuItem") + // .HasName("PRIMARY") + // .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + // j.ToTable("bestellungsposition_has_menuitem"); + // j.HasIndex(new[] { "MenuItemIdmenuItem" }, "fk_Bestellungsposition_has_MenuItem_MenuItem1"); + // j.IndexerProperty("BestellungspositionIdbestellung") + // .HasColumnType("int(11)") + // .HasColumnName("Bestellungsposition_IDBestellung"); + // j.IndexerProperty("MenuItemIdmenuItem") + // .HasColumnType("int(11)") + // .HasColumnName("MenuItem_IDMenuItem"); + // }); }); modelBuilder.Entity(entity => @@ -212,16 +214,16 @@ public partial class WebApiContext : DbContext entity.Property(e => e.Password).HasMaxLength(100); }); - //modelBuilder.Entity(entity => - //{ - // entity.HasKey(e => new { e.BestellungspositionId, e.MenuitemId }) - // .HasName("PRIMARY"); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.Bestellungsposition_IDBestellung, e.MenuItem_IDMenuItem }) + .HasName("PRIMARY"); - // entity.ToTable("bestellungsposition_has_menuitem"); + entity.ToTable("bestellungsposition_has_menuitem"); - // entity.Property(e => e.BestellungspositionId).HasColumnType("int(11)"); - // entity.Property(e => e.MenuitemId).HasColumnType("int(11)"); - //}); + 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/WebApi/Models/Bestellungsposition.cs b/src/WebApi/Models/Bestellungsposition.cs index 64c3048..f641a12 100644 --- a/src/WebApi/Models/Bestellungsposition.cs +++ b/src/WebApi/Models/Bestellungsposition.cs @@ -1,23 +1,23 @@ using System; using System.Collections.Generic; -namespace WebApi.Models; +namespace WebApi.Models; public partial class Bestellungsposition { - public int Idbestellung { get; set; } + public int Idbestellung { get; set; } - public int? Menge { get; set; } + public int? Menge { get; set; } - public DateTime? Datum { get; set; } + public DateTime? Datum { get; set; } - public int KundeIdkunde { get; set; } + public int KundeIdkunde { get; set; } - public int RabattIdrabatt { get; set; } + public int? RabattIdrabatt { get; set; } - public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; + public virtual Kunde? KundeIdkundeNavigation { get; set; } = null!; - public virtual Rabatt RabattIdrabattNavigation { get; set; } = null!; + public virtual Rabatt? RabattIdrabattNavigation { get; set; } = null!; - public virtual ICollection MenuItemIdmenuItems { get; set; } = new List(); + public virtual ICollection? MenuItemIdmenuItems { get; set; } = new List(); } diff --git a/src/WebApi/Models/BestellungspositionHasMenuitem.cs b/src/WebApi/Models/BestellungspositionHasMenuitem.cs new file mode 100644 index 0000000..5edaa6c --- /dev/null +++ b/src/WebApi/Models/BestellungspositionHasMenuitem.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace WebApi.Models; + +public partial class BestellungspositionHasMenuitem +{ + public int? Bestellungsposition_IDBestellung { get; set; } + + public int? MenuItem_IDMenuItem { get; set; } +} 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..5210136 100644 --- a/src/y4f/Pages/Index.razor +++ b/src/y4f/Pages/Index.razor @@ -1,20 +1,65 @@ - @page "/" - @layout Startseite +@page "/" +@layout Startseite +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager +@inject IJSRuntime JSRuntime; 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"); + 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 + { + 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 19d32d7..1c27340 100644 --- a/src/y4f/Pages/ShoppingCart.razor +++ b/src/y4f/Pages/ShoppingCart.razor @@ -91,8 +91,8 @@
- - + +   Uhr
@@ -111,7 +111,7 @@
@@ -121,9 +121,31 @@ - - @code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + public int hour; + public int minute; + private void UpdateTime() + { + localStorage.SetItem("Hour", hour); + localStorage.SetItem("Minute", minute); + } + + private void SetBestllung() + { + if (menuitemIds.Count == 0) + { + return; + } + UpdateTime(); + localStorage.SetItem>("MenuItemIds", menuitemIds); + _navigationManager.NavigateTo("/Bestellabschluss"); + } + + + public decimal summe; public Dictionary menuitemIds = new Dictionary(); @@ -163,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(); @@ -171,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) { @@ -180,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"); @@ -199,6 +230,17 @@ } } } + localStorage.SetItem("Summe", summe); + + // if hour/minute is set, set the values + if (localStorage.GetItem("Hour") != 0) + { + hour = localStorage.GetItem("Hour"); + } + if (localStorage.GetItem("Minute") != 0) + { + minute = localStorage.GetItem("Minute"); + } } public class Allergie @@ -219,7 +261,7 @@ public int KundeIdkunde { get; set; } - public int RabattIdrabatt { get; set; } + public int? RabattIdrabatt { get; set; } public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; diff --git a/src/y4f/Pages/Speisekarte.razor b/src/y4f/Pages/Speisekarte.razor index b61de9f..651dc26 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

@@ -23,18 +26,39 @@ @item2.Bezeichnung + @if (@item2.Bezeichnung == "Nachspeise") + { + +
+ + } } else if (@item.Bezeichnung == "Japanisch") { @item2.Bezeichnung + @if (@item2.Bezeichnung == "Nachspeise") + { + +
+ + } + } else if (@item.Bezeichnung == "Getränke") { @item2.Bezeichnung + @if (@item2.Bezeichnung == "Bier") + { + +
+ +
+ + } } else if (@item.Bezeichnung == "Sonstiges") { @@ -44,15 +68,9 @@ } else { - - @item2.Bezeichnung - } } } - -
-
@@ -70,11 +88,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 +128,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 b43edb3..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"); @@ -148,7 +163,7 @@ public int KundeIdkunde { get; set; } - public int RabattIdrabatt { get; set; } + public int? RabattIdrabatt { get; set; } public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; diff --git a/src/y4f/Pages/SpeisekarteDrDetails.razor b/src/y4f/Pages/SpeisekarteDrDetails.razor index b591b8f..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"); @@ -154,7 +168,7 @@ public int KundeIdkunde { get; set; } - public int RabattIdrabatt { get; set; } + public int? RabattIdrabatt { get; set; } public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; diff --git a/src/y4f/Pages/SpeisekarteEtcDetails.razor b/src/y4f/Pages/SpeisekarteEtcDetails.razor index d015804..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"); @@ -156,7 +169,7 @@ public int KundeIdkunde { get; set; } - public int RabattIdrabatt { get; set; } + public int? RabattIdrabatt { get; set; } public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; diff --git a/src/y4f/Pages/SpeisekarteJpDetails.razor b/src/y4f/Pages/SpeisekarteJpDetails.razor index 06ee43c..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"); @@ -150,7 +164,7 @@ public int KundeIdkunde { get; set; } - public int RabattIdrabatt { get; set; } + public int? RabattIdrabatt { get; set; } public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; 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 a11af9e..c4553e1 100644 --- a/src/y4f/Shared/Bestellabschluss.razor +++ b/src/y4f/Shared/Bestellabschluss.razor @@ -1,36 +1,341 @@ @page "/Bestellabschluss" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager -
-

Sie haben derzeit 1 Yummy-Punkt(e)

-

Bei einem Mindestbestellwert von 8€ erhalten Sie ein Yummy-Punkt. - Ab der 10ten Bestellung gibt es einen Rabatt zu Ihrer nächsten Bestellung.

- -
- @for(int i = 0; i < 10; i++) - { - - } -
-
- -

Achtung: Bitte beachten Sie, dass keine online Bezahlung zur Verfügung steht. - Diese dient nur zur Vorbestellung und muss selbst abgeholt werden.

- -
-
- -
+
+

Sie haben derzeit @kunde.Treuepunkte Yummy-Punkt(e)

+

+ Bei einem Mindestbestellwert von 8€ erhalten Sie ein Yummy-Punkt. + Ab der 10ten Bestellung gibt es einen Rabatt (@rabatt.Prozent%) zu Ihrer nächsten Bestellung. +

-
- -
-
+
+ @for (int i = 0; i < 10; i++) + { + @*if kunde hat treuepunkte*@ + @if (kunde.Treuepunkte > i) + { + + } + else + { + + } + } +
+
+

+ Achtung: Bitte beachten Sie, dass keine online Bezahlung zur Verfügung steht. + Diese dient nur zur Vorbestellung und muss selbst abgeholt werden. +

+

+ Ihr gesamt bestellter Betrag beträgt: @summe € +

+ @*if treuepunkte 10 dann angebot bieten*@ + @if (kunde.Treuepunkte == 10) + { +

Sie haben 10 Yummy-Punkte erreicht. Sie können diese jetzt einlösen und erhalten einen Rabatt von @rabatt.Prozent%.

+

Wollen Sie diese einlösen?

-
+ @if (rabattEinloesen == true) + { +

Betrag beträgt abzüglich des Rabattes: @Math.Round(summe - (summe * rabatt.Prozent / 100), 2) €

+ } + } +
+
+ Zurück +
+
+ +
+
+
-@code { - -} + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + private List rabatte = new List(); + private Rabatt rabatt = new Rabatt(); + private bool rabattEinloesen; + + public Dictionary menuitemIds = new Dictionary(); + + public List bestellungspositionen = new List(); + public int hour; + public int minute; + + public decimal summe; + + public void Vorbestellen() + { + // set rabattEinloesen + if (rabattEinloesen) + { + kunde.Treuepunkte = 0; + // delete treuepunkte API + Http.PutAsJsonAsync("https://localhost:7076/api/kunden/" + kunde.Idkunde, kunde); + summe = Math.Round(summe - (summe * rabatt.Prozent / 100), 2); + localStorage.SetItem("Summe", summe); + localStorage.SetItem("RabattEinloesen", true); + } + else + { + localStorage.SetItem("RabattEinloesen", false); + localStorage.SetItem("Summe", summe); + if (summe >= 8) + { + if (kunde.Treuepunkte < 10) + { + kunde.Treuepunkte++; + Http.PutAsJsonAsync("https://localhost:7076/api/kunden/" + kunde.Idkunde, kunde); + } + } + } + + // add bestellung to API + // add all bestellungspositionen to API + // get latest bestellungsposition id wenn nix da dann 0 + int bestellungspositionId = 0; + if (bestellungspositions != null) + { + // get the highest id from bestellungspositions + int highestId; + foreach (var item in bestellungspositions) + { + highestId = item.Idbestellung; + if (highestId > bestellungspositionId) + { + bestellungspositionId = highestId; + } + } + } + + foreach (var item in menuitemIds) + { + bestellungspositionId++; + Bestellungsposition bestellungsposition = new Bestellungsposition(); + bestellungsposition.Idbestellung = bestellungspositionId; + bestellungsposition.Menge = item.Value; + // make a new date with hour and minute + DateTime abholzeit = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hour, minute, 0); + bestellungsposition.Datum = abholzeit; + // latest possible rabatt + if (rabattEinloesen) + { + bestellungsposition.RabattIdrabatt = rabatt.Idrabatt; + } + else + { + bestellungsposition.RabattIdrabatt = null; + } + bestellungsposition.KundeIdkunde = kunde.Idkunde; + + Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionen", bestellungsposition); + + ////Add menuitems to bestellungspositionHasMenuItem + //BestellungspositionHasMenuitem bestellungspositionHasMenuItem = new BestellungspositionHasMenuitem(); + //bestellungspositionHasMenuItem.Bestellungsposition_IDBestellung = bestellungsposition.Idbestellung; + //bestellungspositionHasMenuItem.MenuItem_IDMenuItem = item.Key; + + //Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionhasmenuitems", bestellungspositionHasMenuItem); + + var newBestellungsposition = new BestellungspositionHasMenuitem() + { + Bestellungsposition_IDBestellung = bestellungsposition.Idbestellung, + MenuItem_IDMenuItem = item.Key + }; + + Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionhasmenuitems", newBestellungsposition); + } + + + // delete all localStorage + localStorage.SetItem("MenuItemIds", new Dictionary()); + localStorage.SetItem("Summe", 0); + localStorage.SetItem("RabattEinloesen", false); + + _navigationManager.NavigateTo("/Bestellbestätigung"); + } + + // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt + private List allergien = new List(); + private List bestellungspositions = new List(); + private List menuitems = new List(); + private List menuitemkategories = new List(); + private List menuitemueberkategories = 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 + allergien = await Http.GetFromJsonAsync>("https://localhost:7076/api/allergien"); + bestellungspositions = await Http.GetFromJsonAsync>("https://localhost:7076/api/bestellungspositionen"); + 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"); + rabatte = await Http.GetFromJsonAsync>("https://localhost:7076/api/Rabatte"); + bestellungspositionHasMenuitems = await Http.GetFromJsonAsync>("https://localhost:7076/api/BestellungspositionHasMenuitems"); + + // get kunde from local storage + kunde = localStorage.GetItem("kunde"); + + // get the most recent rabatt, that are still valid (GueltigkeitBis) + // if there is no rabatt, set the rabatt to null + if (rabatte.Count == 0) + { + rabatt = null; + } + else + { + for (int i = 0; i < rabatte.Count; i++) + { + if (rabatte[i].GueltigkeitBis > DateTime.Now) + { + rabatt = rabatte[i]; + } + } + } + + // get data from localstorage + if (localStorage.GetItem>("MenuItemIds") != null) + { + menuitemIds = localStorage.GetItem>("MenuItemIds"); + } + + // calculate the sum of all menuitems + summe = 0; + foreach (var item in menuitemIds) + { + foreach (var item2 in menuitems) + { + if (item.Key == item2.IdmenuItem) + { + summe += item2.Preis * item.Value; + } + } + } + + // if hour/minute is set, set the values + if (localStorage.GetItem("Hour") != 0) + { + hour = localStorage.GetItem("Hour"); + } + if (localStorage.GetItem("Minute") != 0) + { + minute = localStorage.GetItem("Minute"); + } + } + + public class Allergie + { + public int Idallergie { get; set; } + + public string? Beschreibung { get; set; } + + public virtual ICollection MenuItemIdmenuItems { get; set; } = new List(); + } + public class Bestellungsposition + { + public int Idbestellung { get; set; } + + public int? Menge { get; set; } + + public DateTime? Datum { get; set; } + + public int KundeIdkunde { get; set; } + + public int? RabattIdrabatt { get; set; } + + + } + public class Kunde + { + public int Idkunde { get; set; } + + public string? Code { get; set; } + + public int? Treuepunkte { get; set; } + + public virtual ICollection Bestellungspositions { get; set; } = new List(); + } + + public class Menuitem + { + public int IdmenuItem { get; set; } + + public string? Bezeichnung { get; set; } + + public string? Zusatzinformation { get; set; } + + public decimal Preis { get; set; } + + public int MenuItemKategorieIdmenuItemKategorie { get; set; } + + public virtual Menuitemkategorie MenuItemKategorieIdmenuItemKategorieNavigation { get; set; } = null!; + + public virtual ICollection AllergieIdallergies { get; set; } = new List(); + + public virtual ICollection BestellungspositionIdbestellungs { get; set; } = new List(); + } + public class Menuitemkategorie + { + public int IdmenuItemKategorie { get; set; } + + public string? Bezeichnung { get; set; } + + public int MenuItemUeberkategorieIdmenuItemUeberkategorie { get; set; } + + public virtual Menuitemueberkategorie MenuItemUeberkategorieIdmenuItemUeberkategorieNavigation { get; set; } = null!; + + public virtual ICollection Menuitems { get; set; } = new List(); + } + + public class Menuitemueberkategorie + { + public int IdmenuItemUeberkategorie { get; set; } + + public string? Bezeichnung { get; set; } + + public virtual ICollection Menuitemkategories { get; set; } = new List(); + } + + public class Rabatt + { + public int Idrabatt { get; set; } + + public decimal Prozent { get; set; } + + public DateTime? GueltigkeitVon { get; set; } + + public DateTime? GueltigkeitBis { get; set; } + + public bool Einloesen { get; set; } + public virtual ICollection Bestellungspositions { get; set; } = new List(); + } + + + public class BestellungspositionHasMenuitem + { + 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 760eedf..a670d08 100644 --- a/src/y4f/Shared/Bestellbestätigung.razor +++ b/src/y4f/Shared/Bestellbestätigung.razor @@ -1,38 +1,241 @@ @page "/Bestellbestätigung" +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + -
-
Vielen Dank für Ihre Bestellung

-

- Ihr Essen ist in 30 Minuten abholbereit. - Sie erhalten eine Benachrichtigung sobald das Essen fertig ist. Wir würden uns freuen, wenn Sie uns ein Feedback geben. -



-

+
+
Vielen Dank für Ihre Bestellung

+

+ Ihr Essen ist heute um @hour:@minute abholbereit. + Sie erhalten eine Benachrichtigung sobald das Essen fertig ist. Wir würden uns freuen, wenn Sie uns ein Feedback geben. +



+

-
-
-
+
+
+
- +
- - - - - -
Bestellung eingegangenBestellung wird zubereitetEssen abholbereit
- -
-



-
- -
-
+ + Bestellung eingegangen + Bestellung wird zubereitet + Essen abholbereit + + -
+
+



+
+ +
+
+ +
-@code { - + + + + + + + +@code { + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + private List rabatte = new List(); + private Rabatt rabatt = new Rabatt(); + private bool rabattEinloesen; + + public Dictionary menuitemIds = new Dictionary(); + + public int hour; + public int minute; + + public decimal summe; + + + + public void BestellungsUuebersicht() + { + _navigationManager.NavigateTo("/Kontoverwaltung"); + } + + // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt + private List allergien = new List(); + private List bestellungspositions = new List(); + private List menuitems = new List(); + private List menuitemkategories = new List(); + private List menuitemueberkategories = 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 + 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"); + rabatte = await Http.GetFromJsonAsync>("https://localhost:7076/api/Rabatte"); + + // get kunde from local storage + kunde = localStorage.GetItem("kunde"); + + // get the most recent rabatt, that are still valid (GueltigkeitBis) + // if there is no rabatt, set the rabatt to null + if (rabatte.Count == 0) + { + rabatt = null; + } + else + { + for (int i = 0; i < rabatte.Count; i++) + { + if (rabatte[i].GueltigkeitBis > DateTime.Now) + { + rabatt = rabatte[i]; + } + } + } + + // get data from localstorage + if (localStorage.GetItem>("MenuItemIds") != null) + { + menuitemIds = localStorage.GetItem>("MenuItemIds"); + } + + // calculate the sum of all menuitems + summe = 0; + foreach (var item in menuitemIds) + { + foreach (var item2 in menuitems) + { + if (item.Key == item2.IdmenuItem) + { + summe += item2.Preis * item.Value; + } + } + } + + // if hour/minute is set, set the values + if (localStorage.GetItem("Hour") != 0) + { + hour = localStorage.GetItem("Hour"); + } + if (localStorage.GetItem("Minute") != 0) + { + minute = localStorage.GetItem("Minute"); + } + + // + } + + public class Allergie + { + public int Idallergie { get; set; } + + public string? Beschreibung { get; set; } + + public virtual ICollection MenuItemIdmenuItems { get; set; } = new List(); + } + public class Bestellungsposition + { + public int Idbestellung { get; set; } + + public int? Menge { get; set; } + + public DateTime? Datum { get; set; } + + public int KundeIdkunde { get; set; } + + public int? RabattIdrabatt { get; set; } + + public virtual Kunde KundeIdkundeNavigation { get; set; } = null!; + + public virtual Rabatt RabattIdrabattNavigation { get; set; } = null!; + + public virtual ICollection MenuItemIdmenuItems { get; set; } = new List(); + } + public class Kunde + { + public int Idkunde { get; set; } + + public string? Code { get; set; } + + public int? Treuepunkte { get; set; } + + public virtual ICollection Bestellungspositions { get; set; } = new List(); + } + + public class Menuitem + { + public int IdmenuItem { get; set; } + + public string? Bezeichnung { get; set; } + + public string? Zusatzinformation { get; set; } + + public decimal Preis { get; set; } + + public int MenuItemKategorieIdmenuItemKategorie { get; set; } + + public virtual Menuitemkategorie MenuItemKategorieIdmenuItemKategorieNavigation { get; set; } = null!; + + public virtual ICollection AllergieIdallergies { get; set; } = new List(); + + public virtual ICollection BestellungspositionIdbestellungs { get; set; } = new List(); + } + public class Menuitemkategorie + { + public int IdmenuItemKategorie { get; set; } + + public string? Bezeichnung { get; set; } + + public int MenuItemUeberkategorieIdmenuItemUeberkategorie { get; set; } + + public virtual Menuitemueberkategorie MenuItemUeberkategorieIdmenuItemUeberkategorieNavigation { get; set; } = null!; + + public virtual ICollection Menuitems { get; set; } = new List(); + } + + public class Menuitemueberkategorie + { + public int IdmenuItemUeberkategorie { get; set; } + + public string? Bezeichnung { get; set; } + + public virtual ICollection Menuitemkategories { get; set; } = new List(); + } + + public class Rabatt + { + public int Idrabatt { get; set; } + + public decimal? Prozent { get; set; } + + public DateTime? GueltigkeitVon { get; set; } + + public DateTime? GueltigkeitBis { get; set; } + + public bool Einloesen { get; set; } + public virtual ICollection Bestellungspositions { get; set; } = new List(); + } } diff --git a/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor b/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor index 0a4fc53..30b50cd 100644 --- a/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor +++ b/src/y4f/Shared/Chefin/Bestelluebersicht-Chefin.razor @@ -1,82 +1,173 @@ @page "/Bestelluebersicht" @layout ChefinLayout +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + +@*// logout button*@ +
+ +
-
-
-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+
+

+
Aktive Bestellungen
#1234   12:30#2345   18:45
#3456   13:00#4567   19:00
#5678   14:30#6789   19:15
#4321   15:15#5432   19:15
#6543   15:30#7654   19:15
#7654   15:30 
#8765   16:00 
#9876   17:30 
+ + + + + + + @*iterate all kunden*@ + @foreach (var kunde in kunden) + { + bool firstTime = true; + @*if kunde has made a recent bestellungsposiotn from today and higher value than now, print it*@ + @foreach (var bestellungsposition in bestellungspositions) + { + if (bestellungsposition.KundeIdkunde == kunde.Idkunde) + { + @*get the last highes datum from Datum*@ + if (firstTime) + { + @*if (bestellungsposition.Datum == bestellungspositions.Max(x => x.Datum))*@ + @*{*@ + @*get hour and minute from datetime of last bestellungsposition*@ + hour = bestellungsposition.Datum.Hour; + minute = bestellungsposition.Datum.Minute; + day = bestellungsposition.Datum.Day; + month = bestellungsposition.Datum.Month; + year = bestellungsposition.Datum.Year; - -
Aktive Bestellungen @day.@month.@year
-
-
-

Abholzeit

-
-
- -
-
- -
-
- -
- -
-
+ @*print only if date is higher than now datum, all expired hh:mm unvisible *@ + @*if (bestellungsposition.Datum > DateTime.Now) + { + + +

+ #@kunde.Code   + @hour:@minute +

+ + + }*@ + @*print only if date is in current day month year *@ + if (bestellungsposition.Datum.Day == DateTime.Now.Day && bestellungsposition.Datum.Month == DateTime.Now.Month && bestellungsposition.Datum.Year == DateTime.Now.Year) + { + + +

+ #@kunde.Code   + @hour:@minute +

+ + + } + firstTime = false; + } + } + } + } + + +
+
+ @*

Abholzeit

+
+
+ +
+
+ +
+
+ +
*@ + +
+
@code { + public int hour; + public int minute; + public int day; + public int month; + public int year; + + private List bestellungspositions = new List(); + private List kunden = new List(); + private Kunde kunde = new Kunde(); + + + public void Logout() + { + localStorage.Clear(); + _navigationManager.NavigateTo("/"); + } + public void BDetail(int id) + { + localStorage.SetItem("KundeId", id); + _navigationManager.NavigateTo("/BestelluebersichtD-Chefin"); + } + + protected override async Task OnInitializedAsync() + { + // get data from api + bestellungspositions = await Http.GetFromJsonAsync>("https://localhost:7076/api/bestellungspositionen"); + kunden = await Http.GetFromJsonAsync>("https://localhost:7076/api/kunden"); + // set hour, minute, day , month, year to now date + hour = DateTime.Now.Hour; + minute = DateTime.Now.Minute; + day = DateTime.Now.Day; + month = DateTime.Now.Month; + year = DateTime.Now.Year; + + //sort bestellungspositions by datum + bestellungspositions = bestellungspositions.OrderByDescending(x => x.Datum).ToList(); + //sort kunden by the order of bestellungspositions + List kundenSorted = new List(); + foreach (var bestellungsposition in bestellungspositions) + { + foreach (var kunde in kunden) + { + if (bestellungsposition.KundeIdkunde == kunde.Idkunde && !kundenSorted.Contains(kunde)) + { + kundenSorted.Add(kunde); + } + } + } + kunden = kundenSorted; + + } + + public class Bestellungsposition + { + public int Idbestellung { get; set; } + + public int Menge { get; set; } + + public DateTime Datum { get; set; } + + public int KundeIdkunde { get; set; } + + public int? RabattIdrabatt { get; set; } + + } + public class Kunde + { + public int Idkunde { get; set; } + + public string Code { get; set; } + + public int Treuepunkte { get; set; } + } + } + diff --git a/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor b/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor index 37c6193..e3bedc4 100644 --- a/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor +++ b/src/y4f/Shared/Chefin/BestelluebersichtD-Chefin.razor @@ -1,131 +1,117 @@ @page "/BestelluebersichtD-Chefin" @layout ChefinLayout +@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + + +@*// logout button*@ +
+ +
-
-
- @*Tabelle Ihre Bestellung*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ihre Bestellung
- 1 Nudel mit Hühnerfleisch (groß) -
mit Knoblauchsoße
-
9,10€
1 Coca Cola2,50€
Summe11,60€
-
+
-
-
- -
-
- - - - - - - - - - - - -
-

Abholzeit

-
-
-
-

12:30 Uhr

-
-
-
+
+ @*Tabelle Ihre Bestellung*@ +
+ + + + + + + + + @if (menuitemIds.Count == 0) + { +
+
Warenkorb ist leer
+
+ } + else + { + @foreach (var item in menuitemIds) + { + @foreach (var item2 in menuitems) + { + @if (item.Key == item2.IdmenuItem) + { + -
- - - -
+ + + + } + } - - - - + } + } + + + + + + + +
Ihre Bestellung (@day.@month.@year)
+ @item.Value x + @item2.Bezeichnung +
@item2.Zusatzinformation
+
@(item2.Preis * item.Value)€
Summe + @summe€   + @if (rabattEinloesen) + { + (- @rabatt.Prozent%) + } +
+ +
+ +
+
+ +
+
+ + + + + + + + + + + + +
+

Abholzeit

+
+
+
+

@hour:@minute Uhr (@day.@month.@year)

+
+
+
+ +
+ @**@ + @**@ + @**@ +
+ +
+
+
+
+ + @*Buttons*@ + +
- @*Buttons*@ - -
- @*
@*Essen Abholen? @@ -134,6 +120,177 @@
*@ + @code { + public int hour; + public int minute; + public int day; + public int month; + public int year; + + + public decimal summe; + public Dictionary menuitemIds = new Dictionary(); + private Rabatt rabatt = new Rabatt(); + private bool rabattEinloesen; + + public decimal rabattGutschrift; + + + 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(); + + public void Logout() + { + localStorage.Clear(); + _navigationManager.NavigateTo("/"); + } + + //public void Aufloesen() + //{ + // foreach (var bestellungsposition in bestellungspositions) + // { + // foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems) + // { + // if (bestellungsposition.Idbestellung == bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung) + // { + // Http.DeleteAsync("https://localhost:7076/api/BestellungspositionHasMenuitems/" + bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung + "/" + bestellungspositionHasMenuitem.MenuItem_IDMenuItem); + // } + // } + // if (bestellungsposition.KundeIdkunde == kunde.Idkunde) + // { + // Http.DeleteAsync("https://localhost:7076/api/Bestellungspositionen/" + bestellungsposition.Idbestellung); + // } + // } + //} + + protected override async Task OnInitializedAsync() + { + // get data from api + 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"); + rabatte = await Http.GetFromJsonAsync>("https://localhost:7076/api/Rabatte"); + bestellungspositionHasMenuitems = await Http.GetFromJsonAsync>("https://localhost:7076/api/BestellungspositionHasMenuitems"); + + + // get kunde from localstorage + int kundeId = localStorage.GetItem("KundeId"); + kunde = kunden.Where(x => x.Idkunde == kundeId).FirstOrDefault(); + + // get all menuitemIds from bestellungspositions with the last date + foreach (var bestellungsposition in bestellungspositions) + { + if (bestellungsposition.KundeIdkunde == kunde.Idkunde) + { + //if (bestellungsposition.Datum == bestellungspositions.Max(x => x.Datum)) + //{ + + // get hour and minute from datetime of last bestellungsposition + hour = bestellungsposition.Datum.Hour; + minute = bestellungsposition.Datum.Minute; + day = bestellungsposition.Datum.Day; + month = bestellungsposition.Datum.Month; + year = bestellungsposition.Datum.Year; + + //if rabatt is used + if (bestellungsposition.RabattIdrabatt != null) + { + rabattEinloesen = true; + foreach (var rabatt in rabatte) + { + if (rabatt.Idrabatt == bestellungsposition.RabattIdrabatt) + { + this.rabatt = rabatt; + } + } + } + + foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems) + { + if (bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung == bestellungsposition.Idbestellung) + { + menuitemIds.Add(bestellungspositionHasMenuitem.MenuItem_IDMenuItem, bestellungsposition.Menge); + } + } + //} + } + } + // get summe + foreach (var menuitem in menuitems) + { + foreach (var menuitemId in menuitemIds) + { + if (menuitem.IdmenuItem == menuitemId.Key) + { + summe += menuitem.Preis * menuitemId.Value; + } + } + } + //if rabatt is used calculate new summe + if (rabattEinloesen) + { + rabattGutschrift = (summe * rabatt.Prozent / 100); + summe = summe - rabattGutschrift; + summe = Math.Round(summe, 2); + } + } + + public class Bestellungsposition + { + public int Idbestellung { get; set; } + + public int Menge { get; set; } + + public DateTime Datum { get; set; } + + public int KundeIdkunde { get; set; } + + public int? RabattIdrabatt { get; set; } + + } + public class Kunde + { + public int Idkunde { get; set; } + + public string? Code { get; set; } + + public int? Treuepunkte { get; set; } + } + + public class Menuitem + { + public int IdmenuItem { get; set; } + + public string? Bezeichnung { get; set; } + + public string? Zusatzinformation { get; set; } + + public decimal Preis { get; set; } + + + } + public class Rabatt + { + public int Idrabatt { get; set; } + + public decimal Prozent { get; set; } + + public DateTime? GueltigkeitVon { get; set; } + + public DateTime? GueltigkeitBis { get; set; } + + } + + public class BestellungspositionHasMenuitem + { + public int Bestellungsposition_IDBestellung { get; set; } + public int MenuItem_IDMenuItem { get; set; } + } } + 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 c74a919..6c2ddc5 100644 --- a/src/y4f/Shared/Kontoverwaltung.razor +++ b/src/y4f/Shared/Kontoverwaltung.razor @@ -1,30 +1,304 @@ @page "/Kontoverwaltung" -

Wichtige Informationen


+@inject HttpClient Http +@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage +@inject NavigationManager _navigationManager + +

Wichtige Informationen

+
+@*log out Button *@ +
+ +
+
-

AccountID: @RegistrierungA.userName

-

Ihr QR-Code:

- +

AccountID: @kunde.Code

+

Ihr QR-Code:

+ + +


Ihr Konto wird 30 Tage nach der Deaktivierung unwiderruflich gelöscht.

+ -


Ihr Konto wird 30 Tage nach der Deaktivierung unwiderruflich gelöscht.

- -
-

+
+

Bestellübersicht

+ +
+
+
+ +
+
+
+ @*Tabelle Ihre Bestellung*@ +
+ + + + + + + + + @if (menuitemIds.Count == 0) + { +
+
Warenkorb ist leer
+
+ } + else + { + @foreach (var item in menuitemIds) + { + @foreach (var item2 in menuitems) + { + @if (item.Key == item2.IdmenuItem) + { + + + + + + } + } + } + } + + + + + + + +
Ihre Bestellung (@day.@month.@year)
+ @item.Value x + @item2.Bezeichnung +
@item2.Zusatzinformation
+
@(item2.Preis * item.Value)€
Summe + @summe€   + @if (rabattEinloesen) + { + (- @rabatt.Prozent%) + } + +
+ +
+ +
+
+ +
+
+ + + + + + + + + + + + +
+

Abholzeit

+
+
+
+

@hour:@minute Uhr (@day.@month.@year)

+
+
+
+
+ @**@ + @**@ + @**@ +
+ +
+
+
+
+
+ + + @code { - bool changeButtonBool { get; set; } = true; + private List kunden = new List(); + private Kunde kunde = new Kunde(); - string button1 => changeButtonBool ? "Konto deaktivieren" : "Konto aktivieren"; + bool changeButtonBool { get; set; } = true; - void ChangeButton() - { - //TODO Datenbankaktualisierung - changeButtonBool = !changeButtonBool; - } + string button1 => changeButtonBool ? "Konto deaktivieren" : "Konto aktivieren"; + + void ChangeButton() + { + //TODO Datenbankaktualisierung + changeButtonBool = !changeButtonBool; + } + + public void Logout() + { + localStorage.Clear(); + _navigationManager.NavigateTo("/"); + } + + public int hour; + public int minute; + public int day; + public int month; + public int year; + + + public decimal summe; + public Dictionary menuitemIds = new Dictionary(); + private Rabatt rabatt = new Rabatt(); + private bool rabattEinloesen; + + public decimal rabattGutschrift; + + + private List bestellungspositions = new List(); + 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"); + menuitems = await Http.GetFromJsonAsync>("https://localhost:7076/api/Menuitems"); + rabatte = await Http.GetFromJsonAsync>("https://localhost:7076/api/Rabatte"); + bestellungspositionHasMenuitems = await Http.GetFromJsonAsync>("https://localhost:7076/api/BestellungspositionHasMenuitems"); + + // get kunde from local storage + kunde = localStorage.GetItem("kunde"); + + // get all menuitemIds from bestellungspositions with the last date + foreach (Bestellungsposition bestellungsposition in bestellungspositions) + { + if (bestellungsposition.KundeIdkunde == kunde.Idkunde) + { + + // get hour and minute from datetime of last bestellungsposition + hour = bestellungsposition.Datum.Hour; + minute = bestellungsposition.Datum.Minute; + day = bestellungsposition.Datum.Day; + month = bestellungsposition.Datum.Month; + year = bestellungsposition.Datum.Year; + + //if rabatt is used + if (bestellungsposition.RabattIdrabatt != null) + { + rabattEinloesen = true; + foreach (var rabatt in rabatte) + { + if (rabatt.Idrabatt == bestellungsposition.RabattIdrabatt) + { + this.rabatt = rabatt; + } + } + } + + foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems) + { + if (bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung == bestellungsposition.Idbestellung) + { + menuitemIds.Add(bestellungspositionHasMenuitem.MenuItem_IDMenuItem, bestellungsposition.Menge); + } + } + } + } + // get summe + foreach (var menuitem in menuitems) + { + foreach (var menuitemId in menuitemIds) + { + if (menuitem.IdmenuItem == menuitemId.Key) + { + summe += menuitem.Preis * menuitemId.Value; + } + } + } + //if rabatt is used calculate new summe + if (rabattEinloesen) + { + rabattGutschrift = (summe * rabatt.Prozent / 100); + summe = summe - rabattGutschrift; + summe = Math.Round(summe, 2); + } + } + + public class Bestellungsposition + { + public int Idbestellung { get; set; } + + public int Menge { get; set; } + + public DateTime Datum { get; set; } + + public int KundeIdkunde { get; set; } + + public int? RabattIdrabatt { get; set; } + + } + public class Kunde + { + public int Idkunde { get; set; } + + public string? Code { get; set; } + + public int? Treuepunkte { get; set; } + } + + public class Menuitem + { + public int IdmenuItem { get; set; } + + public string? Bezeichnung { get; set; } + + public string? Zusatzinformation { get; set; } + + public decimal Preis { get; set; } + + + } + public class Rabatt + { + public int Idrabatt { get; set; } + + public decimal Prozent { get; set; } + + public DateTime? GueltigkeitVon { get; set; } + + public DateTime? GueltigkeitBis { get; set; } + + } + + public class BestellungspositionHasMenuitem + { + public int Bestellungsposition_IDBestellung { get; set; } + public int MenuItem_IDMenuItem { get; set; } + } } 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 @@ -