Compare commits

..

2 Commits

Author SHA1 Message Date
MET18937
075d2a4838 Update shoppingcart 2023-06-23 20:04:29 +02:00
MET18937
04a221f20b Update speisekarte2 details 2023-06-23 20:04:11 +02:00
8 changed files with 485 additions and 199 deletions

View File

@ -1,5 +1,7 @@
@page "/shopping_cart" @page "/shopping_cart"
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager
<PageTitle>Warenkorb</PageTitle> <PageTitle>Warenkorb</PageTitle>
<h1>Warenkorb</h1> <h1>Warenkorb</h1>
@ -23,54 +25,44 @@
</tr> </tr>
</thead> </thead>
<tbody class="bg_lightgreen"> <tbody class="bg_lightgreen">
@if (menuitemIds.Count == 0)
{
<div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">Warenkorb ist leer</h5>
</div>
}
else
{
@foreach (var item in menuitemIds)
{
@foreach (var item2 in menuitems)
{
@if (item.Key == item2.IdmenuItem)
{
<tr> <tr>
<td class="br" style="padding-top:20px; padding-bottom:0px; border-bottom-width: 0px;"> <td class="br" style="padding-top:20px; padding-bottom:0px; border-bottom-width: 0px;">
1 Nudel mit Hühnerfleisch (groß) @item.Value x
<div style="font-size:0.7rem;padding-left:15px;">mit Knoblauchsoße</div> @item2.Bezeichnung
<button @onclick="@(() => DelMenuItemId(item.Key))" class="btn btn-danger">del</button>
<div style="font-size:0.7rem;padding-left:15px;">@item2.Zusatzinformation</div>
</td> </td>
<td class="d-flex justify-content-center align-items-center" style="padding-top:20px; padding-bottom:0px;">9,10€</td> <td class="d-flex justify-content-center align-items-center" style="padding-top:20px; border-bottom-width:0px;">@(item2.Preis * item.Value)€</td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;">1 Coca Cola</td>
<td class="d-flex justify-content-center align-items-center" style="padding-top:0px;">2,50€</td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center"></td>
</tr>
<tr>
<td class="br" style=" padding-top:0px; border-bottom-width: 0px;"></td>
<td class="d-flex justify-content-center align-items-center" style="border-bottom-width: 0px;"></td>
</tr> </tr>
}
}
}
}
</tbody> </tbody>
<tfoot class="bg_lightgreen"> <tfoot class="bg_lightgreen">
<tr style="border-top:solid 1px black;"> <tr style="border-top:solid 1px black;">
<th class="" style="text-align:right;">Summe</th> <th class="" style="text-align:right;">Summe</th>
<td class="d-flex justify-content-center align-items-center">11,60€</td> <td class="d-flex justify-content-center align-items-center">
@summe€
</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@ -81,7 +73,7 @@
<div class="col-sm-12 col-lg-6"> <div class="col-sm-12 col-lg-6">
<div class="h-100"> <div class="h-100">
@*Essen Abholen?*@ @*Essen Abholen?*@
<div class="row h-25 w-100"> <div class="row h-25 w-100 ">
<div class="col"> <div class="col">
<div class="d-flex flex-column align-items-center "> <div class="d-flex flex-column align-items-center ">
<div class="tbl-container bdr w-100"> <div class="tbl-container bdr w-100">
@ -116,10 +108,10 @@
@*Buttons*@ @*Buttons*@
<div class="row h-75 w-100"> <div class="row h-75 w-100">
<div class="col mt-auto"> <div class="col mt-auto ">
<div class="d-flex flex-column align-items-center "> <div class="d-flex flex-column align-items-center ">
<button class="btn_back w-75">Zurück</button> <a href="/speisekarte" class="btn_bg w-75 btn text-center">Zurück</a>
<button class="btn_forward w-75">Weiter</button> <a href="#" class="btn_forward btn w-75 ">Weiter</a>
</div> </div>
</div> </div>
</div> </div>
@ -127,3 +119,175 @@
</div> </div>
</div> </div>
</div> </div>
@code {
public decimal summe;
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
private void SetMenuItemId(int id)
{
if (menuitemIds.ContainsKey(id))
{
menuitemIds[id]++;
}
else
{
menuitemIds.Add(id, 1);
}
localStorage.SetItem<Dictionary<int, int>>("MenuItemIds", menuitemIds);
}
private void DelMenuItemId(int id)
{
if (menuitemIds.ContainsKey(id))
{
if (menuitemIds[id] > 1)
{
menuitemIds[id]--;
}
else
{
menuitemIds.Remove(id);
}
}
localStorage.SetItem<Dictionary<int, int>>("MenuItemIds", menuitemIds);
_navigationManager.NavigateTo(_navigationManager.Uri, forceLoad: true);
}
// allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt
private List<Allergie> allergien = new List<Allergie>();
private List<Bestellungsposition> bestellungspositions = new List<Bestellungsposition>();
private List<Kunde> kunden = new List<Kunde>();
private List<Menuitem> menuitems = new List<Menuitem>();
private List<Menuitemkategorie> menuitemkategories = new List<Menuitemkategorie>();
private List<Menuitemueberkategorie> menuitemueberkategories = new List<Menuitemueberkategorie>();
private List<Rabatt> rabatte = new List<Rabatt>();
protected override async Task OnInitializedAsync()
{
// get data from localstorage
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
// get data from api
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
menuitems = await Http.GetFromJsonAsync<List<Menuitem>>("https://localhost:7076/api/Menuitems");
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");
rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte");
// 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;
}
}
}
}
public class Allergie
{
public int Idallergie { get; set; }
public string? Beschreibung { get; set; }
public virtual ICollection<Menuitem> MenuItemIdmenuItems { get; set; } = new List<Menuitem>();
}
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<Menuitem> MenuItemIdmenuItems { get; set; } = new List<Menuitem>();
}
public class Kunde
{
public int Idkunde { get; set; }
public string? Code { get; set; }
public int? Treuepunkte { get; set; }
public virtual ICollection<Bestellungsposition> Bestellungspositions { get; set; } = new List<Bestellungsposition>();
}
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<Allergie> AllergieIdallergies { get; set; } = new List<Allergie>();
public virtual ICollection<Bestellungsposition> BestellungspositionIdbestellungs { get; set; } = new List<Bestellungsposition>();
}
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<Menuitem> Menuitems { get; set; } = new List<Menuitem>();
}
public class Menuitemueberkategorie
{
public int IdmenuItemUeberkategorie { get; set; }
public string? Bezeichnung { get; set; }
public virtual ICollection<Menuitemkategorie> Menuitemkategories { get; set; } = new List<Menuitemkategorie>();
}
public class Rabatt
{
public int Idrabatt { get; set; }
public decimal? Prozent { get; set; }
public DateTime? GueltigkeitVon { get; set; }
public DateTime? GueltigkeitBis { get; set; }
public virtual ICollection<Bestellungsposition> Bestellungspositions { get; set; } = new List<Bestellungsposition>();
}
}

View File

@ -1,6 +1,7 @@
@page "/SpeisekarteChinesich" @page "/SpeisekarteChinesich"
@inject HttpClient Http @inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
<h1>Speisekarte Chinesisch</h1> <h1>Speisekarte Chinesisch</h1>
<div class="container"> <div class="container">
@ -25,7 +26,7 @@
{ {
if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie) if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie)
{ {
<div class="card mt-3 "> <div class="card mt-3 " @onclick="@(() => SetMenuItemId(item3.IdmenuItem))">
<div class="card-body"> <div class="card-body">
@*create two divs columns*@ @*create two divs columns*@
<div class="row"> <div class="row">
@ -53,30 +54,55 @@
<div class="card-header"> <div class="card-header">
Warenkorb Warenkorb
</div> </div>
@if (menuitemIds.Count == 0)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Nudeln mit Hühnerfleisch</h5> <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">Warenkorb ist leer</h5>
<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">9.10€</span></p>
</div> </div>
}
else
{
@foreach (var item in menuitemIds)
{
@foreach (var item2 in menuitems)
{
@if (item.Key == item2.IdmenuItem)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Coca Cola</h5> <p>@item.Value</p>
@*<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>*@ <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">@item2.Bezeichnung</h5>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">3.10€</span></p> <p class="card-text" style="font-size:8pt;margin-bottom:0px;">@item2.Zusatzinformation</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">@item2.Preis</span></p>
</div> </div>
}
}
}
}
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column mb-5">
<a href="#" class="btn btn-primary mx-2 mt-5">Zurück</a> <a href="/speisekarte" class="btn btn-primary mx-2 mt-5">Zurück</a>
<a href="#" class="btn btn-primary mx-2 mt-1">Weiter</a> <a href="/shopping_cart" class="btn btn-primary mx-2 mt-1 mb-5">Weiter</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@code { @code {
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
private void SetMenuItemId(int id)
{
if (menuitemIds.ContainsKey(id))
{
menuitemIds[id]++;
}
else
{
menuitemIds.Add(id, 1);
}
localStorage.SetItem<Dictionary<int, int>>("MenuItemIds", menuitemIds);
}
// allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt
private List<Allergie> allergien = new List<Allergie>(); private List<Allergie> allergien = new List<Allergie>();
@ -89,6 +115,11 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien"); allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen"); bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden"); kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
@ -96,6 +127,7 @@
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories"); menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories"); menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");
rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte"); rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte");
} }
public class Allergie public class Allergie

View File

@ -1,6 +1,7 @@
@page "/SpeisekarteGetraenke" @page "/SpeisekarteGetraenke"
@inject HttpClient Http @inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
<h1>Speisekarte Getränke</h1> <h1>Speisekarte Getränke</h1>
@* create an container bootstrap 5*@ @* create an container bootstrap 5*@
@ -27,7 +28,7 @@
if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie) if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie)
{ {
<div class="card mt-3 "> <div class="card mt-3 " @onclick="@(() => SetMenuItemId(item3.IdmenuItem))">
<div class="card-body"> <div class="card-body">
@*create two divs columns*@ @*create two divs columns*@
<div class="row"> <div class="row">
@ -45,12 +46,9 @@
} }
} }
} }
}
} }
} }
}
</div> </div>
<div class="col-4"> <div class="col-4">
@* warenkorb anzeige als bootstrap card*@ @* warenkorb anzeige als bootstrap card*@
@ -58,24 +56,35 @@
<div class="card-header"> <div class="card-header">
Warenkorb Warenkorb
</div> </div>
@if (menuitemIds.Count == 0)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Nudeln mit Hühnerfleisch</h5> <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">Warenkorb ist leer</h5>
<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">9.10€</span></p>
</div> </div>
}
else
{
@foreach (var item in menuitemIds)
{
@foreach (var item2 in menuitems)
{
@if (item.Key == item2.IdmenuItem)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Coca Cola</h5> <p>@item.Value</p>
@*<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>*@ <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">@item2.Bezeichnung</h5>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">3.10€</span></p> <p class="card-text" style="font-size:8pt;margin-bottom:0px;">@item2.Zusatzinformation</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">@item2.Preis</span></p>
</div> </div>
}
}
}
}
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column mb-5">
<a href="#" class="btn btn-primary mx-2 mt-5">Zurück</a> <a href="/speisekarte" class="btn btn-primary mx-2 mt-5">Zurück</a>
<a href="#" class="btn btn-primary mx-2 mt-1">Weiter</a> <a href="/shopping_cart" class="btn btn-primary mx-2 mt-1 mb-5">Weiter</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -84,6 +93,23 @@
@code { @code {
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
private void SetMenuItemId(int id)
{
if (menuitemIds.ContainsKey(id))
{
menuitemIds[id]++;
}
else
{
menuitemIds.Add(id, 1);
}
localStorage.SetItem<Dictionary<int, int>>("MenuItemIds", menuitemIds);
}
// allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt
private List<Allergie> allergien = new List<Allergie>(); private List<Allergie> allergien = new List<Allergie>();
@ -96,6 +122,11 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien"); allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen"); bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden"); kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");

View File

@ -1,6 +1,7 @@
@page "/SpeisekarteSonstiges" @page "/SpeisekarteSonstiges"
@inject HttpClient Http @inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
<h1>Speisekarte Sonstiges</h1> <h1>Speisekarte Sonstiges</h1>
@* create an container bootstrap 5*@ @* create an container bootstrap 5*@
@ -18,7 +19,7 @@
@foreach (var item in menuitemueberkategories) @foreach (var item in menuitemueberkategories)
{ {
@if (item.Bezeichnung == "Japanisch") @if (item.Bezeichnung == "Sonstiges")
{ {
@foreach (var item2 in menuitemkategories) @foreach (var item2 in menuitemkategories)
{ {
@ -29,7 +30,7 @@
if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie) if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie)
{ {
<div class="card mt-3 "> <div class="card mt-3 " @onclick="@(() => SetMenuItemId(item3.IdmenuItem))">
<div class="card-body"> <div class="card-body">
@*create two divs columns*@ @*create two divs columns*@
<div class="row"> <div class="row">
@ -58,24 +59,35 @@
<div class="card-header"> <div class="card-header">
Warenkorb Warenkorb
</div> </div>
@if (menuitemIds.Count == 0)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Nudeln mit Hühnerfleisch</h5> <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">Warenkorb ist leer</h5>
<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">9.10€</span></p>
</div> </div>
}
else
{
@foreach (var item in menuitemIds)
{
@foreach (var item2 in menuitems)
{
@if (item.Key == item2.IdmenuItem)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Coca Cola</h5> <p>@item.Value</p>
@*<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>*@ <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">@item2.Bezeichnung</h5>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">3.10€</span></p> <p class="card-text" style="font-size:8pt;margin-bottom:0px;">@item2.Zusatzinformation</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">@item2.Preis</span></p>
</div> </div>
}
}
}
}
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column mb-5">
<a href="#" class="btn btn-primary mx-2 mt-5">Zurück</a> <a href="/speisekarte" class="btn btn-primary mx-2 mt-5">Zurück</a>
<a href="#" class="btn btn-primary mx-2 mt-1">Weiter</a> <a href="/shopping_cart" class="btn btn-primary mx-2 mt-1 mb-5">Weiter</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -86,6 +98,21 @@
@code { @code {
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
private void SetMenuItemId(int id)
{
if (menuitemIds.ContainsKey(id))
{
menuitemIds[id]++;
}
else
{
menuitemIds.Add(id, 1);
}
localStorage.SetItem<Dictionary<int, int>>("MenuItemIds", menuitemIds);
}
// allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt
private List<Allergie> allergien = new List<Allergie>(); private List<Allergie> allergien = new List<Allergie>();
@ -98,6 +125,10 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien"); allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen"); bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden"); kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");

View File

@ -1,6 +1,7 @@
@page "/SpeisekarteJapanisch" @page "/SpeisekarteJapanisch"
@inject HttpClient Http @inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
<h1>Speisekarte Japanisch</h1> <h1>Speisekarte Japanisch</h1>
@* create an container bootstrap 5*@ @* create an container bootstrap 5*@
@ -14,8 +15,6 @@
<button type="button" class="btn">Bento</button> <button type="button" class="btn">Bento</button>
<button type="button" class="btn">Nachspeise</button> <button type="button" class="btn">Nachspeise</button>
</div> </div>
@foreach (var item in menuitemueberkategories) @foreach (var item in menuitemueberkategories)
{ {
@if (item.Bezeichnung == "Japanisch") @if (item.Bezeichnung == "Japanisch")
@ -28,8 +27,7 @@
{ {
if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie) if (item2.IdmenuItemKategorie == item3.MenuItemKategorieIdmenuItemKategorie)
{ {
<div class="card mt-3" @onclick="@(() => SetMenuItemId(item3.IdmenuItem))">
<div class="card mt-3 ">
<div class="card-body"> <div class="card-body">
@*create two divs columns*@ @*create two divs columns*@
<div class="row"> <div class="row">
@ -47,12 +45,9 @@
} }
} }
} }
}
} }
} }
}
</div> </div>
<div class="col-4"> <div class="col-4">
@* warenkorb anzeige als bootstrap card*@ @* warenkorb anzeige als bootstrap card*@
@ -60,24 +55,35 @@
<div class="card-header"> <div class="card-header">
Warenkorb Warenkorb
</div> </div>
@if (menuitemIds.Count == 0)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Nudeln mit Hühnerfleisch</h5> <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">Warenkorb ist leer</h5>
<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">9.10€</span></p>
</div> </div>
}
else
{
@foreach (var item in menuitemIds)
{
@foreach (var item2 in menuitems)
{
@if (item.Key == item2.IdmenuItem)
{
<div class="card-body"> <div class="card-body">
<h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">1 Coca Cola</h5> <p>@item.Value</p>
@*<p class="card-text" style="font-size:8pt;margin-bottom:0px;">mit Knoblauchsoße</p>*@ <h5 class="card-title" style="font-size:10pt; margin-bottom:0px;">@item2.Bezeichnung</h5>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">3.10€</span></p> <p class="card-text" style="font-size:8pt;margin-bottom:0px;">@item2.Zusatzinformation</p>
<p class="card-text" id="preis" style="text-align:right; "><span style="background-color:#c7ffd5; border-radius:20px; font-size:10pt; padding:5px">@item2.Preis</span></p>
</div> </div>
}
}
}
}
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column mb-5">
<a href="#" class="btn btn-primary mx-2 mt-5">Zurück</a> <a href="/speisekarte" class="btn btn-primary mx-2 mt-5">Zurück</a>
<a href="#" class="btn btn-primary mx-2 mt-1">Weiter</a> <a href="/shopping_cart" class="btn btn-primary mx-2 mt-1 mb-5">Weiter</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -86,6 +92,21 @@
@code { @code {
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
private void SetMenuItemId(int id)
{
if (menuitemIds.ContainsKey(id))
{
menuitemIds[id]++;
}
else
{
menuitemIds.Add(id, 1);
}
localStorage.SetItem<Dictionary<int, int>>("MenuItemIds", menuitemIds);
}
// allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt // allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt
private List<Allergie> allergien = new List<Allergie>(); private List<Allergie> allergien = new List<Allergie>();
@ -98,6 +119,10 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (localStorage.GetItem<Dictionary<int, int>>("MenuItemIds") != null)
{
menuitemIds = localStorage.GetItem<Dictionary<int, int>>("MenuItemIds");
}
allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien"); allergien = await Http.GetFromJsonAsync<List<Allergie>>("https://localhost:7076/api/allergien");
bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen"); bestellungspositions = await Http.GetFromJsonAsync<List<Bestellungsposition>>("https://localhost:7076/api/bestellungspositionen");
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden"); kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");

View File

@ -1,3 +1,4 @@
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using y4f; using y4f;
@ -6,7 +7,7 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app"); builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after"); builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

View File

@ -11,6 +11,7 @@
border-radius: 17px; border-radius: 17px;
overflow: hidden; overflow: hidden;
border-color: #C7FFD5; border-color: #C7FFD5;
border-width: 0px;
} }
.bg_lightgreen { .bg_lightgreen {
@ -23,19 +24,19 @@
border-bottom-width: 0; border-bottom-width: 0;
} }
.btn_back { .btn_bg {
background-color: #F9BE89; background-color: #F9BE89;
/*width: 60%;*/ /*width: 60%;*/
margin-bottom: 13px; margin-bottom: 13px;
border-radius: 30px; border-radius: 30px;
height: 50px; /*height: 50px;*/
border: 0px; /*border: 0px;*/
} }
.btn_forward { .btn_forward {
background-color: #89F9A5; background-color: #89F9A5;
/*width: 60%;*/ /*width: 60%;*/
border-radius: 30px; border-radius: 30px;
height: 50px; /*height: 50px;*/
border: 0px; /*border: 0px;*/
} }

View File

@ -26,6 +26,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
</ItemGroup> </ItemGroup>