Compare commits

...

2 Commits

Author SHA1 Message Date
MET18937
72cffa664e Add kontaktverwaltung Bestellübersicht 2023-06-25 17:16:22 +02:00
MET18937
8d4d8338aa Add complete vorbestellungsfunktion 2023-06-25 16:42:33 +02:00
9 changed files with 295 additions and 40 deletions

View File

@ -13,7 +13,7 @@ public partial class Bestellungsposition
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde? KundeIdkundeNavigation { get; set; } = null!;

View File

@ -249,7 +249,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde KundeIdkundeNavigation { get; set; } = null!;

View File

@ -148,7 +148,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde KundeIdkundeNavigation { get; set; } = null!;

View File

@ -154,7 +154,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde KundeIdkundeNavigation { get; set; } = null!;

View File

@ -156,7 +156,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde KundeIdkundeNavigation { get; set; } = null!;

View File

@ -150,7 +150,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde KundeIdkundeNavigation { get; set; } = null!;

View File

@ -116,12 +116,19 @@
DateTime abholzeit = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hour, minute, 0);
bestellungsposition.Datum = abholzeit;
// latest possible rabatt
bestellungsposition.RabattIdrabatt = rabatt.Idrabatt;
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
//Add menuitems to bestellungspositionHasMenuItem
BestellungspositionHasMenuitem bestellungspositionHasMenuItem = new BestellungspositionHasMenuitem();
bestellungspositionHasMenuItem.Bestellungsposition_IDBestellung = bestellungsposition.Idbestellung;
bestellungspositionHasMenuItem.MenuItem_IDMenuItem = item.Key;
@ -131,8 +138,8 @@
// delete all localStorage
localStorage.SetItem("MenuItemIds", new Dictionary<int, int>());
localStorage.SetItem("Hour", 0);
localStorage.SetItem("Minute", 0);
//localStorage.SetItem("Hour", 0);
//localStorage.SetItem("Minute", 0);
localStorage.SetItem("Summe", 0);
localStorage.SetItem("RabattEinloesen", false);
@ -227,7 +234,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
}

View File

@ -29,8 +29,7 @@
<div class="button">
<br><br><br><br>
<form id="button1" action="/">
<input type="submit" value="Bestellungsübersicht" class="btn">
@*<input type="submit" value="Zur Startseite" class="btn">*@
<input type="submit" value="Bestellungsübersicht" class="btn" @onclick="BestellungsUuebersicht"/>
</form>
</div>
@ -60,17 +59,11 @@
public decimal summe;
public void Vorbestellen()
public void BestellungsUuebersicht()
{
// set rabattEinloesen
if (rabattEinloesen)
localStorage.SetItem("RabattEinloesen", true);
else
localStorage.SetItem("RabattEinloesen", false);
_navigationManager.NavigateTo("/Bestellbestätigung");
_navigationManager.NavigateTo("/Kontoverwaltung");
}
// allergien, bestellungsposition, kunde, menuitem, menuitemkategorie, menuitemueberkategorie, rabatt
@ -161,7 +154,7 @@
public int KundeIdkunde { get; set; }
public int RabattIdrabatt { get; set; }
public int? RabattIdrabatt { get; set; }
public virtual Kunde KundeIdkundeNavigation { get; set; } = null!;

View File

@ -1,34 +1,289 @@
@page "/Kontoverwaltung"
<h3>Wichtige Informationen</h3> <br>
@inject HttpClient Http
@inject Blazored.LocalStorage.ISyncLocalStorageService localStorage
@inject NavigationManager _navigationManager
<h3>Wichtige Informationen</h3>
<br>
<div class="container mt-auto">
<h4>AccountID: @RegistrierungA.userName</h4>
<h4>Ihr QR-Code: </h4>
<img src="assets/K-QR.png" class="img" title="logo image">
<h4>AccountID: @kunde.Code</h4>
<h4>Ihr QR-Code: </h4>
<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 class="container mt-auto">
<h1>Bestellübersicht</h1>
<h1>Bestellübersicht</h1>
</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 {
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; }
}
}