BaseDataWindow: Fix crash when CurrentLastSeason does not exist
All checks were successful
Test / Run tests (push) Successful in 2m8s

This commit is contained in:
2024-05-12 22:34:53 +02:00
parent 8eba40a8c1
commit f95f0f0ef3

View File

@ -148,7 +148,7 @@ namespace Elwig.Windows {
protected override async Task OnRenewContext(AppDbContext ctx) { protected override async Task OnRenewContext(AppDbContext ctx) {
await base.OnRenewContext(ctx); await base.OnRenewContext(ctx);
FillInputs(App.Client, (await ctx.Seasons.FindAsync(Utils.CurrentLastSeason))!); FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons
.OrderByDescending(s => s.Year) .OrderByDescending(s => s.Year)
.Include(s => s.Modifiers) .Include(s => s.Modifiers)
@ -274,7 +274,7 @@ namespace Elwig.Windows {
using var ctx = new AppDbContext(); using var ctx = new AppDbContext();
ClearInputStates(); ClearInputStates();
FillInputs(App.Client, (await ctx.Seasons.FindAsync(Utils.CurrentLastSeason))!); FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
LockInputs(); LockInputs();
} }
@ -294,7 +294,7 @@ namespace Elwig.Windows {
using var ctx = new AppDbContext(); using var ctx = new AppDbContext();
ClearInputStates(); ClearInputStates();
FillInputs(App.Client, (await ctx.Seasons.FindAsync(Utils.CurrentLastSeason))!); FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
UpdateButtons(); UpdateButtons();
} }
@ -325,14 +325,14 @@ namespace Elwig.Windows {
using (var ctx = new AppDbContext()) { using (var ctx = new AppDbContext()) {
ClearInputStates(); ClearInputStates();
FillInputs(App.Client, (await ctx.Seasons.FindAsync(Utils.CurrentLastSeason))!); FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
LockInputs(); LockInputs();
} }
await HintContextChange(); await HintContextChange();
} }
private void FillInputs(ClientParameters p, Season s) { private void FillInputs(ClientParameters p, Season? s) {
ClearOriginalValues(); ClearOriginalValues();
ClearDefaultValues(); ClearDefaultValues();
@ -363,9 +363,9 @@ namespace Elwig.Windows {
TextElementDeliveryConfirmation.Text = p.TextDeliveryConfirmation; TextElementDeliveryConfirmation.Text = p.TextDeliveryConfirmation;
TextElementCreditNote.Text = p.TextCreditNote; TextElementCreditNote.Text = p.TextCreditNote;
ParameterAllowAttrIntoLowerInput.IsChecked = s.Billing_AllowAttrsIntoLower; ParameterAllowAttrIntoLowerInput.IsChecked = s?.Billing_AllowAttrsIntoLower ?? false;
ParameterAvoidUnderDeliveriesInput.IsChecked = s.Billing_AvoidUnderDeliveries; ParameterAvoidUnderDeliveriesInput.IsChecked = s?.Billing_AvoidUnderDeliveries ?? false;
ParameterHonorGebundenInput.IsChecked = s.Billing_HonorGebunden; ParameterHonorGebundenInput.IsChecked = s?.Billing_HonorGebunden ?? false;
FinishInputFilling(); FinishInputFilling();
} }