Add kontaktverwaltung Bestellübersicht

This commit is contained in:
MET18937 2023-06-25 17:16:22 +02:00
parent 8d4d8338aa
commit 72cffa664e

View File

@ -4,35 +4,286 @@
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage @inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager @inject NavigationManager _navigationManager
<h3>Wichtige Informationen</h3> <br> <h3>Wichtige Informationen</h3>
<br>
<div class="container mt-auto"> <div class="container mt-auto">
<h4>AccountID: @RegistrierungA.userName</h4> <h4>AccountID: @kunde.Code</h4>
<h4>Ihr QR-Code: </h4> <h4>Ihr QR-Code: </h4>
<img src="assets/K-QR.png" class="img" title="logo image"> <img src="assets/K-QR.png" class="img" title="logo image">
<p><br>Ihr Konto wird 30 Tage nach der Deaktivierung unwiderruflich gelöscht.</p>
<button class="btn" type="button" onclick="@ChangeButton" id="button1">@button1</button>
<p><br>Ihr Konto wird 30 Tage nach der Deaktivierung unwiderruflich gelöscht.</p>
<button class="btn" type="button" onclick="@ChangeButton" id="button1">@button1</button>
</div> </div>
<div class="container mt-auto"> <div class="container mt-auto">
<h1>Bestellübersicht</h1> <h1>Bestellübersicht</h1>
</div> </div>
<br><br> <br>
<br>
<div class="container">
<div class="row">
<div class="col-sm-12 col-lg-6">
@*Tabelle Ihre Bestellung*@
<div class="tbl-container">
<table class="table bdr">
<thead class="bg_green">
<tr>
<td>Ihre Bestellung (@day.@month.@year)</td>
<th></th>
</tr>
</thead>
<tbody class="bg_lightgreen" style="background-color:white;">
@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>
<td class="br" style="padding-top:20px; padding-bottom:0px; border-bottom-width: 0px;">
@item.Value x
@item2.Bezeichnung
<div style="font-size:0.7rem;padding-left:15px;">@item2.Zusatzinformation</div>
</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>
}
}
}
}
</tbody>
<tfoot class="bg_lightgreen">
<tr style="border-top:solid 1px black; background-color:white;">
<th class="" style="text-align:right;">Summe</th>
<td class="d-flex justify-content-center align-items-center">
@summe€ &nbsp;
@if (rabattEinloesen)
{
<span style="color:green;">(- @rabatt.Prozent%)</span>
}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="col-sm-12 col-lg-6">
<div class="d-flex flex-column align-items-center ">
<div class="tbl-container w-100">
<!-- <== overflow: hidden applied to parent -->
<table class="table table-bordered bdr " style=" border-radius: 50px; margin-left: 50px;">
<thead class="bg_green">
<tr>
<td class="d-flex justify-content-center align-items-center" style="border-bottom:0px;">
<p>Abholzeit</p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="d-flex justify-content-center align-items-center" style="padding-top:0px; background-color:white;">
<div style="margin:20px;">
<div class="d-flex justify-content-center align-items-center">
<p>@hour:@minute Uhr (@day.@month.@year)</p>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div class="d-flex flex-column" style="align-items: center; margin-left: 100px;">
@*<button class="btn_back w-75">Zurück</button>*@
@*<button class="btn btn-danger w-75" style="border-radius: 50px; padding-top:12px; padding-bottom:12px; color:black;">Bestellung auflösen</button>*@
@*<button class="btn_forward w-75">Bestellung abschließen</button>*@
</div>
</div>
</div>
</div>
</div>
</div>
@code { @code {
bool changeButtonBool { get; set; } = true; bool changeButtonBool { get; set; } = true;
string button1 => changeButtonBool ? "Konto deaktivieren" : "Konto aktivieren"; string button1 => changeButtonBool ? "Konto deaktivieren" : "Konto aktivieren";
void ChangeButton()
{
//TODO Datenbankaktualisierung
changeButtonBool = !changeButtonBool;
}
void ChangeButton() }
{
//TODO Datenbankaktualisierung
changeButtonBool = !changeButtonBool;
} @code {
public int hour;
public int minute;
public int day;
public int month;
public int year;
public decimal summe;
public Dictionary<int, int> menuitemIds = new Dictionary<int, int>();
private Rabatt rabatt = new Rabatt();
private bool rabattEinloesen;
public decimal rabattGutschrift;
private List<Bestellungsposition> bestellungspositions = new List<Bestellungsposition>();
private List<Kunde> kunden = new List<Kunde>();
private Kunde kunde = new Kunde();
private List<Menuitem> menuitems = new List<Menuitem>();
private List<Rabatt> rabatte = new List<Rabatt>();
private List<BestellungspositionHasMenuitem> bestellungspositionHasMenuitems = new List<BestellungspositionHasMenuitem>();
protected override async Task OnInitializedAsync()
{
// get data from api
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");
rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte");
bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems");
// use kudnde with id 1
kunde = kunden[0];
// 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; }
}
} }