Fix kunde.Idkunde access

This commit is contained in:
MET18937 2023-06-25 20:19:03 +02:00
parent d32a517013
commit 8abba97ab8
6 changed files with 88 additions and 86 deletions

View File

@ -83,10 +83,12 @@
Http.PutAsJsonAsync("https://localhost:7076/api/kunden/" + kunde.Idkunde, kunde); Http.PutAsJsonAsync("https://localhost:7076/api/kunden/" + kunde.Idkunde, kunde);
summe = Math.Round(summe - (summe * rabatt.Prozent / 100), 2); summe = Math.Round(summe - (summe * rabatt.Prozent / 100), 2);
localStorage.SetItem("Summe", summe); localStorage.SetItem("Summe", summe);
localStorage.SetItem("RabattEinloesen", true);
} }
else else
{ {
localStorage.SetItem("RabattEinloesen", false); localStorage.SetItem("RabattEinloesen", false);
localStorage.SetItem("Summe", summe);
} }
// add bestellung to API // add bestellung to API
@ -167,7 +169,7 @@
bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems"); bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems");
// test use the first kunde // test use the first kunde
kunde = kunden[0]; kunde = kunden[1];
// get the most recent rabatt, that are still valid (GueltigkeitBis) // get the most recent rabatt, that are still valid (GueltigkeitBis)
// if there is no rabatt, set the rabatt to null // if there is no rabatt, set the rabatt to null

View File

@ -85,7 +85,7 @@
rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte"); rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte");
// test use the first kunde // test use the first kunde
kunde = kunden[0]; kunde = kunden[1];
// get the most recent rabatt, that are still valid (GueltigkeitBis) // get the most recent rabatt, that are still valid (GueltigkeitBis)
// if there is no rabatt, set the rabatt to null // if there is no rabatt, set the rabatt to null

View File

@ -28,29 +28,29 @@
@*get the last highes datum from Datum*@ @*get the last highes datum from Datum*@
if (firstTime) if (firstTime)
{ {
if (bestellungsposition.Datum == bestellungspositions.Max(x => x.Datum)) @*if (bestellungsposition.Datum == bestellungspositions.Max(x => x.Datum))*@
{ @*{*@
@*get hour and minute from datetime of last bestellungsposition*@ @*get hour and minute from datetime of last bestellungsposition*@
hour = bestellungsposition.Datum.Hour; hour = bestellungsposition.Datum.Hour;
minute = bestellungsposition.Datum.Minute; minute = bestellungsposition.Datum.Minute;
day = bestellungsposition.Datum.Day; day = bestellungsposition.Datum.Day;
month = bestellungsposition.Datum.Month; month = bestellungsposition.Datum.Month;
year = bestellungsposition.Datum.Year; year = bestellungsposition.Datum.Year;
@*print kunde.code, hour and minute from last bestellungsposition*@ @*print kunde.code, hour and minute from last bestellungsposition*@
@*print only if date is higher than now datum *@ @*print only if date is higher than now datum *@
if (bestellungsposition.Datum > DateTime.Now) if (bestellungsposition.Datum > DateTime.Now)
{ {
<tr> <tr>
<td> <td>
<p @onclick="@(()=>BDetail(@kunde.Idkunde))" class="mb-0 pb-0"> <p @onclick="@(()=>BDetail(@kunde.Idkunde))" class="mb-0 pb-0">
#@kunde.Code &nbsp; #@kunde.Code &nbsp;
@hour:@minute @hour:@minute
</p> </p>
</td> </td>
</tr> </tr>
}
} }
@*}*@
firstTime = false; firstTime = false;
} }
} }
@ -60,17 +60,17 @@
</table> </table>
</div> </div>
@*<div class="col-lg-3"> @*<div class="col-lg-3">
<p id="text" readonly>Abholzeit</p> <p id="text" readonly>Abholzeit</p>
<br /> <br />
<form id="button" action="Bestelluebersicht"> <form id="button" action="Bestelluebersicht">
<input type="submit" value="30 Min" class="btn"> <input type="submit" value="30 Min" class="btn">
</form> </form>
<form id="button" action="Bestelluebersicht"> <form id="button" action="Bestelluebersicht">
<input type="submit" value="45 Min" class="btn"> <input type="submit" value="45 Min" class="btn">
</form> </form>
<form id="button" action="Bestelluebersicht"> <form id="button" action="Bestelluebersicht">
<input type="submit" value="1 Std" class="btn"> <input type="submit" value="1 Std" class="btn">
</form> </form>
</div>*@ </div>*@
</div> </div>

View File

@ -156,37 +156,37 @@
{ {
if (bestellungsposition.KundeIdkunde == kunde.Idkunde) if (bestellungsposition.KundeIdkunde == kunde.Idkunde)
{ {
if (bestellungsposition.Datum == bestellungspositions.Max(x => x.Datum)) //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;
// get hour and minute from datetime of last bestellungsposition foreach (var rabatt in rabatte)
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; if (rabatt.Idrabatt == bestellungsposition.RabattIdrabatt)
foreach (var rabatt in rabatte)
{ {
if (rabatt.Idrabatt == bestellungsposition.RabattIdrabatt) this.rabatt = rabatt;
{
this.rabatt = rabatt;
}
}
}
foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems)
{
if (bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung == bestellungsposition.Idbestellung)
{
menuitemIds.Add(bestellungspositionHasMenuitem.MenuItem_IDMenuItem, bestellungsposition.Menge);
} }
} }
} }
foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems)
{
if (bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung == bestellungsposition.Idbestellung)
{
menuitemIds.Add(bestellungspositionHasMenuitem.MenuItem_IDMenuItem, bestellungsposition.Menge);
}
}
//}
} }
} }
// get summe // get summe

View File

@ -64,7 +64,6 @@
</tr> </tr>
} }
} }
} }
} }
</tbody> </tbody>
@ -170,42 +169,43 @@
bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems"); bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems");
// use kudnde with id 1 // use kudnde with id 2
kunde = kunden[0]; kunde = kunden[1];
// get all menuitemIds from bestellungspositions with the last date // get all menuitemIds from bestellungspositions with the last date
foreach (var bestellungsposition in bestellungspositions) foreach (Bestellungsposition bestellungsposition in bestellungspositions)
{ {
if (bestellungsposition.KundeIdkunde == kunde.Idkunde) 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;
// get hour and minute from datetime of last bestellungsposition foreach (var rabatt in rabatte)
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; if (rabatt.Idrabatt == bestellungsposition.RabattIdrabatt)
foreach (var rabatt in rabatte)
{ {
if (rabatt.Idrabatt == bestellungsposition.RabattIdrabatt) this.rabatt = rabatt;
{
this.rabatt = rabatt;
}
} }
} }
}
foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems) foreach (var bestellungspositionHasMenuitem in bestellungspositionHasMenuitems)
{
if (bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung == bestellungsposition.Idbestellung)
{ {
if (bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung == bestellungsposition.Idbestellung) menuitemIds.Add(bestellungspositionHasMenuitem.MenuItem_IDMenuItem, bestellungsposition.Menge);
{
menuitemIds.Add(bestellungspositionHasMenuitem.MenuItem_IDMenuItem, bestellungsposition.Menge);
}
} }
} }
} }

View File

@ -62,7 +62,7 @@
kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden"); kunden = await Http.GetFromJsonAsync<List<Kunde>>("https://localhost:7076/api/kunden");
rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte"); rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte");
kunde = kunden[0]; kunde = kunden[1];
// get the most recent rabatt, that are still valid (GueltigkeitBis) // get the most recent rabatt, that are still valid (GueltigkeitBis)
// if there is no rabatt, set the rabatt to null // if there is no rabatt, set the rabatt to null