Services: Make FillInputs synchronous
This commit is contained in:
@ -51,7 +51,7 @@ namespace Elwig.Services {
|
||||
vm.Age = "-";
|
||||
}
|
||||
|
||||
public static async Task FillInputs(this MemberAdminViewModel vm, Member m) {
|
||||
public static void FillInputs(this MemberAdminViewModel vm, Member m) {
|
||||
vm.IsMemberSelected = true;
|
||||
vm.MgNrString = $"{m.MgNr}";
|
||||
vm.PredecessorMgNrString = $"{m.PredecessorMgNr}";
|
||||
@ -137,8 +137,19 @@ namespace Elwig.Services {
|
||||
vm.ContactViaPost = m.ContactViaPost;
|
||||
vm.ContactViaEmail = m.ContactViaEmail;
|
||||
|
||||
Dictionary<int, int> deliveries;
|
||||
using (var ctx = new AppDbContext()) {
|
||||
vm.StatusDeliveriesLastSeasonInfo = "letzte Saison";
|
||||
vm.StatusDeliveriesLastSeason = "-";
|
||||
vm.StatusDeliveriesLastSeasonToolTip = null;
|
||||
vm.StatusDeliveriesThisSeasonInfo = "aktuelle Saison";
|
||||
vm.StatusDeliveriesThisSeason = "-";
|
||||
vm.StatusDeliveriesThisSeasonToolTip = null;
|
||||
vm.StatusAreaCommitmentInfo = "aktuelle Saison";
|
||||
vm.StatusAreaCommitment = "-";
|
||||
vm.StatusAreaCommitmentToolTip = null;
|
||||
|
||||
App.MainDispatcher.BeginInvoke(async () => {
|
||||
using var ctx = new AppDbContext();
|
||||
|
||||
var d1 = ctx.Deliveries.Where(d => d.Year == Utils.CurrentLastSeason - 1 && d.MgNr == m.MgNr);
|
||||
var (_, d1Grid, _, _) = await DeliveryService.GenerateToolTip(d1.SelectMany(d => d.Parts));
|
||||
vm.StatusDeliveriesLastSeasonInfo = $"{Utils.CurrentLastSeason - 1}";
|
||||
@ -161,17 +172,19 @@ namespace Elwig.Services {
|
||||
vm.StatusAreaCommitmentInfo = $"{Utils.CurrentLastSeason}";
|
||||
vm.StatusAreaCommitment = text;
|
||||
vm.StatusAreaCommitmentToolTip = grid;
|
||||
});
|
||||
|
||||
Dictionary<int, bool> deliveries;
|
||||
using (var ctx = new AppDbContext()) {
|
||||
deliveries = ctx.Deliveries
|
||||
.Where(d => d.MgNr == m.MgNr)
|
||||
.SelectMany(d => d.Parts)
|
||||
.GroupBy(d => d.Year)
|
||||
.ToDictionary(g => g.Key, g => g.Sum(d => d.Weight));
|
||||
.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, 0) > 0).ToList();
|
||||
vm.MemberHasDeliveries = Enumerable.Range(0, 9999).Select(i => deliveries.GetValueOrDefault(i, false)).ToList();
|
||||
}
|
||||
|
||||
public static async Task<(List<string>, IQueryable<Member>, List<string>)> GetFilters(this MemberAdminViewModel vm, AppDbContext ctx) {
|
||||
|
Reference in New Issue
Block a user