MemberAdminWindow: Cache MembersDeliveries
All checks were successful
Test / Run tests (push) Successful in 1m46s
All checks were successful
Test / Run tests (push) Successful in 1m46s
This commit is contained in:
@ -174,17 +174,9 @@ namespace Elwig.Services {
|
||||
vm.StatusAreaCommitmentToolTip = grid;
|
||||
});
|
||||
|
||||
Dictionary<int, bool> deliveries;
|
||||
using (var ctx = new AppDbContext()) {
|
||||
deliveries = ctx.Deliveries
|
||||
.Where(d => d.MgNr == m.MgNr)
|
||||
.GroupBy(d => d.Year)
|
||||
.ToDictionary(g => g.Key, g => g.Any());
|
||||
}
|
||||
|
||||
vm.MemberHasEmail = m.EmailAddresses.Count > 0;
|
||||
vm.MemberCanSendEmail = App.Config.Smtp != null && m.EmailAddresses.Count > 0;
|
||||
vm.MemberHasDeliveries = Enumerable.Range(0, 9999).Select(i => deliveries.GetValueOrDefault(i, false)).ToList();
|
||||
vm.MemberHasDeliveries = Enumerable.Range(0, 9999).Select(i => vm.MembersDeliveries.GetValueOrDefault((m.MgNr, i), false)).ToList();
|
||||
}
|
||||
|
||||
public static async Task<(List<string>, IQueryable<Member>, List<string>)> GetFilters(this MemberAdminViewModel vm, AppDbContext ctx) {
|
||||
|
@ -40,6 +40,7 @@ namespace Elwig.ViewModels {
|
||||
private bool _enableSearchInputs = true;
|
||||
[ObservableProperty]
|
||||
private IEnumerable<bool> _memberHasDeliveries = [ .. Enumerable.Range(0, 9999).Select(i => false) ];
|
||||
public Dictionary<(int, int), bool> MembersDeliveries = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _memberListOrderByMgNr;
|
||||
|
@ -187,6 +187,10 @@ namespace Elwig.Windows {
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.Branches.OrderBy(b => b.Name).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(DefaultKgInput, await ctx.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync());
|
||||
|
||||
ViewModel.MembersDeliveries = await ctx.Deliveries
|
||||
.GroupBy(d => new { d.MgNr, d.Year })
|
||||
.ToDictionaryAsync(g => (g.Key.MgNr, g.Key.Year), g => g.Any());
|
||||
|
||||
var seasons = await ctx.Seasons.OrderByDescending(s => s.Year).ToListAsync();
|
||||
Menu_DeliveryConfirmation.Items.Clear();
|
||||
foreach (var s in seasons) {
|
||||
|
Reference in New Issue
Block a user