[#79] AppDbContext: Use compiled queries
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
var areaComCount = await areaComQuery.CountAsync();
|
||||
var season = await ctx.Seasons.FindAsync(await ctx.Seasons.MaxAsync(s => s.Year));
|
||||
var season = await ctx.FetchSeasons().FirstOrDefaultAsync();
|
||||
var stat = await AreaComService.GenerateToolTipData(areaComQuery, season?.MaxKgPerHa ?? 10_000);
|
||||
|
||||
return (filter, contracts, areaComs, areaComCount, stat);
|
||||
@@ -163,7 +163,7 @@ namespace Elwig.Windows {
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
await base.OnRenewContext(ctx);
|
||||
|
||||
if (await ctx.Members.FindAsync(ViewModel.FilterMember.MgNr) is not Member m) {
|
||||
if (await ctx.FetchMembers(ViewModel.FilterMember.MgNr).SingleOrDefaultAsync() is not Member m) {
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
@@ -180,12 +180,8 @@ namespace Elwig.Windows {
|
||||
.Include(c => c.WineAttr)
|
||||
.OrderBy(v => v.VtrgId)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.OrderBy(m => m.Name).ThenBy(m => m.GivenName).ThenBy(m => m.MgNr)
|
||||
.ToListAsync());
|
||||
var cultList = await ctx.WineCultivations
|
||||
.OrderBy(c => c.Name)
|
||||
.Cast<object>().ToListAsync();
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: true).ToListAsync());
|
||||
var cultList = await ctx.FetchWineCultivations().Cast<object>().ToListAsync();
|
||||
cultList.Insert(0, new NullItem());
|
||||
ControlUtils.RenewItemsSource(WineCultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
|
||||
await RefreshList();
|
||||
|
||||
@@ -19,10 +19,7 @@ namespace Elwig.Windows {
|
||||
private bool _branchUpdate = false;
|
||||
|
||||
private async Task BranchesInitEditing(AppDbContext ctx) {
|
||||
_branchList = new(await ctx.Branches
|
||||
.OrderBy(b => b.Name)
|
||||
.Include(b => b.PostalDest)
|
||||
.ToListAsync());
|
||||
_branchList = new(await ctx.FetchBranches().ToListAsync());
|
||||
_branches = _branchList.ToDictionary(b => b.ZwstId, b => (string?)b.ZwstId);
|
||||
_branchIds = _branchList.ToDictionary(b => b, b => b.ZwstId);
|
||||
ControlUtils.RenewItemsSource(BranchList, _branchList);
|
||||
@@ -30,10 +27,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async Task BranchesFinishEditing(AppDbContext ctx) {
|
||||
ControlUtils.RenewItemsSource(BranchList, await ctx.Branches
|
||||
.OrderBy(b => b.Name)
|
||||
.Include(b => b.PostalDest)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(BranchList, await ctx.FetchBranches().ToListAsync());
|
||||
_branchList = null;
|
||||
_branches = null;
|
||||
_branchIds = null;
|
||||
@@ -47,9 +41,10 @@ namespace Elwig.Windows {
|
||||
if (!_branchChanged || _branchList == null || _branches == null || _branchIds == null)
|
||||
return;
|
||||
|
||||
foreach (var (zwstid, _) in _branches.Where(b => b.Value == null)) {
|
||||
ctx.Remove(ctx.Branches.Find(zwstid)!);
|
||||
}
|
||||
var tx = await ctx.Database.BeginTransactionAsync();
|
||||
var deleteZwstIds = _branches.Where(b => b.Value == null).Select(b => b.Key).ToList();
|
||||
await ctx.Branches.Where(b => deleteZwstIds.Contains(b.ZwstId)).ExecuteDeleteAsync();
|
||||
|
||||
foreach (var (branch, old) in _branchIds) {
|
||||
branch.ZwstId = old;
|
||||
}
|
||||
@@ -61,13 +56,13 @@ namespace Elwig.Windows {
|
||||
foreach (var (old, zwstid) in _branches.Where(b => b.Value != null)) {
|
||||
await ctx.Database.ExecuteSqlAsync($"UPDATE branch SET zwstid = {zwstid} WHERE zwstid = {old}");
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
foreach (var branch in _branchList.Where(b => !_branchIds.ContainsKey(b))) {
|
||||
if (branch.ZwstId == null) continue;
|
||||
ctx.Add(branch);
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
await tx.CommitAsync();
|
||||
}
|
||||
|
||||
private void BranchList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
||||
|
||||
@@ -22,10 +22,7 @@ namespace Elwig.Windows {
|
||||
private async Task ModifiersInitEditing(AppDbContext ctx) {
|
||||
SeasonList.IsEnabled = false;
|
||||
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||
_modList = new(await ctx.Modifiers
|
||||
.Where(m => m.Year == year)
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync());
|
||||
_modList = new(await ctx.FetchModifiers(year).ToListAsync());
|
||||
_mods = _modList.ToDictionary(m => m.ModId, m => (string?)m.ModId);
|
||||
_modIds = _modList.ToDictionary(m => m, m => m.ModId);
|
||||
ControlUtils.RenewItemsSource(SeasonModifierList, _modList);
|
||||
@@ -34,10 +31,7 @@ namespace Elwig.Windows {
|
||||
|
||||
private async Task ModifiersFinishEditing(AppDbContext ctx) {
|
||||
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.Modifiers
|
||||
.Where(m => m.Year == year)
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.FetchModifiers(year).ToListAsync());
|
||||
_modList = null;
|
||||
_mods = null;
|
||||
_modIds = null;
|
||||
|
||||
@@ -19,20 +19,14 @@ namespace Elwig.Windows {
|
||||
private async Task SeasonsInitEditing(AppDbContext ctx) {
|
||||
SeasonAddButton.IsEnabled = false;
|
||||
SeasonRemoveButton.IsEnabled = false;
|
||||
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons
|
||||
.OrderByDescending(s => s.Year)
|
||||
.Include(s => s.Modifiers)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(SeasonList, await ctx.FetchSeasons(includeModifiers: true).ToListAsync());
|
||||
SeasonList_SelectionChanged(null, null);
|
||||
}
|
||||
|
||||
private async Task SeasonsFinishEditing(AppDbContext ctx) {
|
||||
SeasonAddButton.IsEnabled = true;
|
||||
SeasonRemoveButton.IsEnabled = true;
|
||||
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons
|
||||
.OrderByDescending(s => s.Year)
|
||||
.Include(s => s.Modifiers)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(SeasonList, await ctx.FetchSeasons(includeModifiers: true).ToListAsync());
|
||||
_seasonChanged = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ namespace Elwig.Windows {
|
||||
private bool _attrUpdate = false;
|
||||
|
||||
private async Task WineAttributesInitEditing(AppDbContext ctx) {
|
||||
_attrList = new(await ctx.WineAttributes
|
||||
.OrderBy(a => a.Name)
|
||||
.ToListAsync());
|
||||
_attrList = new(await ctx.FetchWineAttributes().ToListAsync());
|
||||
_attrs = _attrList.ToDictionary(a => a.AttrId, a => (string?)a.AttrId);
|
||||
_attrIds = _attrList.ToDictionary(a => a, a => a.AttrId);
|
||||
ControlUtils.RenewItemsSource(WineAttributeList, _attrList);
|
||||
@@ -29,9 +27,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async Task WineAttributesFinishEditing(AppDbContext ctx) {
|
||||
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.WineAttributes
|
||||
.OrderBy(a => a.Name)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.FetchWineAttributes().ToListAsync());
|
||||
_attrList = null;
|
||||
_attrs = null;
|
||||
_attrIds = null;
|
||||
@@ -45,9 +41,9 @@ namespace Elwig.Windows {
|
||||
if (!_attrChanged || _attrList == null || _attrs == null || _attrIds == null)
|
||||
return;
|
||||
|
||||
foreach (var (attrid, _) in _attrs.Where(a => a.Value == null)) {
|
||||
ctx.Remove(ctx.WineAttributes.Find(attrid)!);
|
||||
}
|
||||
using var tx = await ctx.Database.BeginTransactionAsync();
|
||||
var deleteAttrIds = _attrs.Where(a => a.Value == null).Select(a => a.Key).ToList();
|
||||
await ctx.WineAttributes.Where(a => deleteAttrIds.Contains(a.AttrId)).ExecuteDeleteAsync();
|
||||
foreach (var (attr, old) in _attrIds) {
|
||||
attr.AttrId = old;
|
||||
}
|
||||
@@ -61,13 +57,13 @@ namespace Elwig.Windows {
|
||||
await ctx.Database.ExecuteSqlAsync($"UPDATE area_commitment_type SET vtrgid = (sortid || COALESCE(attrid, '') || COALESCE(disc, '')) WHERE attrid = {attrid}");
|
||||
await ctx.Database.ExecuteSqlRawAsync($"UPDATE payment_variant SET data = REPLACE(REPLACE(data, '/{old}\"', '/{attrid}\"'), '/{old}-', '/{attrid}-')");
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
foreach (var attr in _attrList.Where(a => !_attrIds.ContainsKey(a))) {
|
||||
if (attr.AttrId == null) continue;
|
||||
ctx.Add(attr);
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
await tx.CommitAsync();
|
||||
}
|
||||
|
||||
private void WineAttributeList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
||||
|
||||
@@ -19,9 +19,7 @@ namespace Elwig.Windows {
|
||||
private bool _cultUpdate = false;
|
||||
|
||||
private async Task WineCultivationsInitEditing(AppDbContext ctx) {
|
||||
_cultList = new(await ctx.WineCultivations
|
||||
.OrderBy(c => c.Name)
|
||||
.ToListAsync());
|
||||
_cultList = new(await ctx.FetchWineCultivations().ToListAsync());
|
||||
_cults = _cultList.ToDictionary(c => c.CultId, c => (string?)c.CultId);
|
||||
_cultIds = _cultList.ToDictionary(c => c, c => c.CultId);
|
||||
ControlUtils.RenewItemsSource(WineCultivationList, _cultList);
|
||||
@@ -29,9 +27,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async Task WineCultivationsFinishEditing(AppDbContext ctx) {
|
||||
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.WineCultivations
|
||||
.OrderBy(c => c.Name)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.FetchWineCultivations().ToListAsync());
|
||||
_cultList = null;
|
||||
_cults = null;
|
||||
_cultIds = null;
|
||||
@@ -45,9 +41,9 @@ namespace Elwig.Windows {
|
||||
if (!_cultChanged || _cultList == null || _cults == null || _cultIds == null)
|
||||
return;
|
||||
|
||||
foreach (var (cultid, _) in _cults.Where(c => c.Value == null)) {
|
||||
ctx.Remove(ctx.WineCultivations.Find(cultid)!);
|
||||
}
|
||||
using var tx = await ctx.Database.BeginTransactionAsync();
|
||||
var deleteCultIds = _cults.Where(c => c.Value == null).Select(c => c.Key).ToList();
|
||||
await ctx.WineCultivations.Where(c => deleteCultIds.Contains(c.CultId)).ExecuteDeleteAsync();
|
||||
foreach (var (cult, old) in _cultIds) {
|
||||
cult.CultId = old;
|
||||
}
|
||||
@@ -60,13 +56,13 @@ namespace Elwig.Windows {
|
||||
await ctx.Database.ExecuteSqlAsync($"UPDATE wine_cultivation SET cultid = {cultid} WHERE cultid = {old}");
|
||||
await ctx.Database.ExecuteSqlRawAsync($"UPDATE payment_variant SET data = REPLACE(data, '-{old}\"', '-{cultid}\"')");
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
foreach (var cult in _cultList.Where(c => !_cultIds.ContainsKey(c))) {
|
||||
if (cult.CultId == null) continue;
|
||||
ctx.Add(cult);
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
await tx.CommitAsync();
|
||||
}
|
||||
|
||||
private void WineCultivationList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
||||
|
||||
@@ -159,35 +159,20 @@ namespace Elwig.Windows {
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
await base.OnRenewContext(ctx);
|
||||
FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
|
||||
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons
|
||||
.OrderByDescending(s => s.Year)
|
||||
.Include(s => s.Modifiers)
|
||||
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
|
||||
ControlUtils.RenewItemsSource(SeasonList, await ctx.FetchSeasons(includeModifiers: true).ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||
ControlUtils.RenewItemsSource(BranchList, await ctx.Branches
|
||||
.OrderBy(b => b.Name)
|
||||
.Include(b => b.PostalDest)
|
||||
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.WineAttributes
|
||||
.OrderBy(a => a.Name)
|
||||
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineVariantInput, await ctx.WineVarieties
|
||||
.OrderBy(s => s.Name)
|
||||
.ToListAsync());
|
||||
var attrList = await ctx.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
ControlUtils.RenewItemsSource(BranchList, await ctx.FetchBranches().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.FetchWineAttributes().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineVariantInput, await ctx.FetchWineVarieties().ToListAsync());
|
||||
var attrList = await ctx.FetchWineAttributes().Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineAttributeInput, attrList);
|
||||
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, await ctx.AreaCommitmentTypes
|
||||
.OrderBy(t => t.VtrgId)
|
||||
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.WineCultivations
|
||||
.OrderBy(c => c.Name)
|
||||
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.Modifiers
|
||||
.Where(m => m.Year == year)
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.FetchWineCultivations().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.FetchModifiers(year).ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
|
||||
}
|
||||
|
||||
protected override void UpdateButtons() {
|
||||
@@ -283,7 +268,7 @@ namespace Elwig.Windows {
|
||||
|
||||
using var ctx = new AppDbContext();
|
||||
ClearInputStates();
|
||||
FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
|
||||
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
@@ -303,7 +288,7 @@ namespace Elwig.Windows {
|
||||
|
||||
using var ctx = new AppDbContext();
|
||||
ClearInputStates();
|
||||
FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
|
||||
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
@@ -339,7 +324,7 @@ namespace Elwig.Windows {
|
||||
|
||||
using (var ctx = new AppDbContext()) {
|
||||
ClearInputStates();
|
||||
FillInputs(App.Client, await ctx.Seasons.FindAsync(Utils.CurrentLastSeason));
|
||||
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
@@ -427,7 +412,7 @@ namespace Elwig.Windows {
|
||||
private async Task UpdateParameters(int year) {
|
||||
try {
|
||||
using var ctx = new AppDbContext();
|
||||
if (await ctx.Seasons.FindAsync(year) is not Season s)
|
||||
if (await ctx.FetchSeasons(year).SingleOrDefaultAsync() is not Season s)
|
||||
return;
|
||||
|
||||
s.Billing_AllowAttrsIntoLower = ParameterAllowAttrIntoLowerInput.IsChecked ?? false;
|
||||
|
||||
@@ -98,17 +98,17 @@ namespace Elwig.Windows {
|
||||
|
||||
private async Task RefreshGraphList(AppDbContext ctx) {
|
||||
PaymentVar = await ctx.PaymentVariants.FindAsync(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
|
||||
Season = await ctx.Seasons.FindAsync(Year) ?? throw new ArgumentException("Season not found");
|
||||
Season = await ctx.FetchSeasons(Year).SingleOrDefaultAsync() ?? throw new ArgumentException("Season not found");
|
||||
CurrencySymbol = Season.Currency.Symbol ?? Season.Currency.Code;
|
||||
PriceInput.Unit = $"{CurrencySymbol}/kg";
|
||||
GebundenFlatBonus.Unit = $"{CurrencySymbol}/kg";
|
||||
|
||||
try {
|
||||
var data = EditBillingData.FromJson(PaymentVar.Data, Utils.GetVaributes(ctx, Year));
|
||||
var paymentEntries = data.GetPaymentGraphEntries(ctx, Season);
|
||||
var data = EditBillingData.FromJson(PaymentVar.Data, await Utils.GetVaributes(ctx, Year));
|
||||
var paymentEntries = await data.GetPaymentGraphEntries(ctx, Season);
|
||||
GraphEntries = [
|
||||
..paymentEntries,
|
||||
..data.GetQualityGraphEntries(ctx, Season, paymentEntries.Any() ? paymentEntries.Max(e => e.Id) : 0)
|
||||
..await data.GetQualityGraphEntries(ctx, Season, paymentEntries.Any() ? paymentEntries.Max(e => e.Id) : 0)
|
||||
];
|
||||
} catch (KeyNotFoundException ex) {
|
||||
var key = ex.Message.Split('\'')[1].Split('\'')[0];
|
||||
@@ -123,7 +123,7 @@ namespace Elwig.Windows {
|
||||
MessageBox.Show("Fehler beim Laden der Auszahlungsvariante:\n\n" + ex.Message, "Fehler",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
Vaributes = Utils.GetVaributeList(ctx, Year);
|
||||
Vaributes = await Utils.GetVaributeList(ctx, Year);
|
||||
GraphEntries.ForEach(e => {
|
||||
e.Vaributes.ForEach(v => {
|
||||
var found = Vaributes.Find(a => a.Variety?.SortId == v.Variety?.SortId && a.Attribute?.AttrId == v.Attribute?.AttrId && a.Cultivation?.CultId == v.Cultivation?.CultId);
|
||||
@@ -642,7 +642,7 @@ namespace Elwig.Windows {
|
||||
await Task.Run(async () => {
|
||||
using var ctx = new AppDbContext();
|
||||
var origData = BillingData.FromJson(PaymentVar.Data);
|
||||
var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetVaributes(ctx, Year),
|
||||
var data = BillingData.FromGraphEntries(GraphEntries, origData, await Utils.GetVaributes(ctx, Year),
|
||||
AllVaributesAssigned, AllVaributesAssignedAbgew);
|
||||
|
||||
PaymentVar.Data = data.ToJsonString();
|
||||
@@ -660,7 +660,7 @@ namespace Elwig.Windows {
|
||||
|
||||
try {
|
||||
await Task.Run(async () => {
|
||||
var b = new BillingVariant(PaymentVar.Year, PaymentVar.AvNr);
|
||||
var b = await BillingVariant.Create(PaymentVar.Year, PaymentVar.AvNr);
|
||||
await b.Calculate(false);
|
||||
});
|
||||
} catch (KeyNotFoundException exc) {
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Elwig.Windows {
|
||||
LockInputs();
|
||||
if (ViewModel.IsReceipt) {
|
||||
NewDeliveryButton_Click(null, null);
|
||||
if (await ctx.Seasons.FindAsync(Utils.CurrentYear) == null) {
|
||||
if (await ctx.FetchSeasons(Utils.CurrentYear).SingleOrDefaultAsync() == null) {
|
||||
MessageBox.Show("Die Saison für das aktuelle Jahr wurde noch nicht erstellt. Neue Lieferungen können nicht abgespeichert werden.\n\n(Stammdaten -> Saisons -> Neu anlegen...)",
|
||||
"Saison noch nicht erstellt", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
@@ -430,7 +430,6 @@ namespace Elwig.Windows {
|
||||
var deliveries = await deliveryQuery
|
||||
.Include(d => d.Parts).ThenInclude(p => p.PartModifiers).ThenInclude(m => m.Modifier)
|
||||
.Include(d => d.Parts).ThenInclude(p => p.Variety)
|
||||
.Include(d => d.Member.EmailAddresses)
|
||||
.IgnoreAutoIncludes()
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
@@ -497,7 +496,7 @@ namespace Elwig.Windows {
|
||||
|
||||
int year = 0;
|
||||
Menu_Bki_SaveList.Items.Clear();
|
||||
foreach (var s in await ctx.Seasons.OrderByDescending(s => s.Year).IgnoreAutoIncludes().ToListAsync()) {
|
||||
foreach (var s in await ctx.FetchSeasons().ToListAsync()) {
|
||||
if (s.Year > year) year = s.Year;
|
||||
var i = new MenuItem {
|
||||
Header = $"Saison {s.Year}",
|
||||
@@ -506,6 +505,9 @@ namespace Elwig.Windows {
|
||||
Menu_Bki_SaveList.Items.Add(i);
|
||||
}
|
||||
|
||||
var attributes = await ctx.FetchWineAttributes(!IsCreating).ToListAsync();
|
||||
var modifiers = await ctx.FetchModifiers(year, !IsCreating).ToListAsync();
|
||||
|
||||
var font = new FontFamily("Segoe MDL2 Assets");
|
||||
Menu_BulkAction_SetAttribute.Items.Clear();
|
||||
var noAttr = new MenuItem {
|
||||
@@ -514,7 +516,7 @@ namespace Elwig.Windows {
|
||||
};
|
||||
noAttr.Click += Menu_BulkAction_SetAttribute_Click;
|
||||
Menu_BulkAction_SetAttribute.Items.Add(noAttr);
|
||||
foreach (var attr in await ctx.WineAttributes.OrderBy(a => a.AttrId).IgnoreAutoIncludes().ToListAsync()) {
|
||||
foreach (var attr in attributes) {
|
||||
var i = new MenuItem {
|
||||
Header = attr.Name,
|
||||
};
|
||||
@@ -524,7 +526,7 @@ namespace Elwig.Windows {
|
||||
|
||||
Menu_BulkAction_AddModifier.Items.Clear();
|
||||
Menu_BulkAction_RemoveModifier.Items.Clear();
|
||||
foreach (var mod in await ctx.Modifiers.Where(m => m.Year == year).OrderBy(m => m.ModId).IgnoreAutoIncludes().ToListAsync()) {
|
||||
foreach (var mod in modifiers) {
|
||||
var i1 = new MenuItem {
|
||||
Header = mod.Name,
|
||||
};
|
||||
@@ -538,27 +540,21 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
await RefreshList();
|
||||
|
||||
var d = DeliveryList.SelectedItem as Delivery;
|
||||
var y = d?.Year ?? ViewModel.FilterSeason;
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive || !IsCreating)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.Branches.OrderBy(b => b.Name).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await ctx.WineVarieties.OrderBy(v => v.Name).ToListAsync());
|
||||
var attrList = await ctx.WineAttributes.Where(a => !IsCreating || a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
var y = d?.Year ?? ViewModel.FilterSeason ?? Utils.CurrentYear;
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !IsCreating, includeContactInfo: true).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.FetchBranches().ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await ctx.FetchWineVarieties().ToListAsync());
|
||||
var attrList = attributes.Cast<object>().ToList();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
|
||||
var cultList = await ctx.WineCultivations.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
var cultList = await ctx.FetchWineCultivations().Cast<object>().ToListAsync();
|
||||
cultList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(CultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
|
||||
WineQualityLevels = await ctx.WineQualityLevels.ToListAsync();
|
||||
WineQualityLevels = await ctx.FetchWineQualityLevels().ToListAsync();
|
||||
ControlUtils.RenewItemsSource(WineQualityLevelInput, WineQualityLevels);
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
|
||||
.Where(m => m.Year == y && (!IsCreating || m.IsActive))
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, modifiers);
|
||||
var origins = await ctx.WineOrigins.ToListAsync();
|
||||
origins.ForEach(o => { origins.FirstOrDefault(p => p.HkId == o.ParentHkId)?.Children.Add(o); });
|
||||
origins = [.. origins.OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId)];
|
||||
@@ -587,16 +583,10 @@ namespace Elwig.Windows {
|
||||
private async Task RefreshDeliveryParts() {
|
||||
using var ctx = new AppDbContext();
|
||||
if (DeliveryList.SelectedItem is Delivery d) {
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
|
||||
.Where(m => m.Year == d.Year && (!IsCreating || m.IsActive))
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.FetchModifiers(d.Year, !IsCreating).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(DeliveryPartList, d.Parts, DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||
} else {
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
|
||||
.Where(m => m.Year == ViewModel.FilterSeason && (!IsCreating || m.IsActive))
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.FetchModifiers(ViewModel.FilterSeason, !IsCreating).ToListAsync());
|
||||
DeliveryPartList.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
@@ -726,7 +716,7 @@ namespace Elwig.Windows {
|
||||
Menu_DeliveryNote_Show.IsEnabled = !IsEditing && !IsCreating;
|
||||
Menu_DeliveryNote_SavePdf.IsEnabled = !IsEditing && !IsCreating;
|
||||
Menu_DeliveryNote_Print.IsEnabled = !IsEditing && !IsCreating;
|
||||
Menu_DeliveryNote_Email.IsEnabled = !IsEditing && !IsCreating && App.Config.Smtp != null && d.Member.EmailAddresses.Count > 0;
|
||||
Menu_DeliveryNote_Email.IsEnabled = !IsEditing && !IsCreating && App.Config.Smtp != null && ViewModel.Member?.EmailAddresses.Count > 0;
|
||||
Menu_Export_ExportSelected.IsEnabled = !IsEditing && !IsCreating;
|
||||
Menu_Export_UploadSelected.IsEnabled = !IsEditing && !IsCreating && App.Config.SyncUrl != null;
|
||||
} else {
|
||||
@@ -884,14 +874,10 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
using var ctx = new AppDbContext();
|
||||
var attrList = await ctx.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
var attrList = await ctx.FetchWineAttributes().Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive || !ViewModel.IsReceipt)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !ViewModel.IsReceipt, includeContactInfo: true).ToListAsync());
|
||||
if (DeliveryList.SelectedItem is not Delivery d) {
|
||||
// switch away from creating mode
|
||||
IsCreating = false;
|
||||
@@ -923,18 +909,11 @@ namespace Elwig.Windows {
|
||||
ViewModel.FilterTodayOnly = true;
|
||||
ViewModel.SearchQuery = "";
|
||||
using var ctx = new AppDbContext();
|
||||
var attrList = await ctx.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
var attrList = await ctx.FetchWineAttributes(false).Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
|
||||
.Where(m => m.Year == ViewModel.FilterSeason && m.IsActive)
|
||||
.OrderBy(m => m.Ordering)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive || !ViewModel.IsReceipt)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.FetchModifiers(ViewModel.FilterSeason, false).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !ViewModel.IsReceipt, includeContactInfo: true).ToListAsync());
|
||||
IsCreating = true;
|
||||
DeliveryList.IsEnabled = false;
|
||||
DeliveryPartList.IsEnabled = false;
|
||||
|
||||
@@ -181,13 +181,8 @@ namespace Elwig.Windows {
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
await base.OnRenewContext(ctx);
|
||||
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive || !IsCreating)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await ctx.WineVarieties.OrderBy(v => v.Name).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !IsCreating).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await ctx.FetchWineVarieties().ToListAsync());
|
||||
|
||||
await RefreshDeliveryScheduleList();
|
||||
await RefreshList();
|
||||
@@ -276,12 +271,7 @@ namespace Elwig.Windows {
|
||||
ViewModel.SelectedDeliveryAncmt = null;
|
||||
|
||||
using var ctx = new AppDbContext();
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive || !IsCreating)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !IsCreating).ToListAsync());
|
||||
|
||||
HideNewEditDeleteButtons();
|
||||
ShowSaveResetCancelButtons();
|
||||
@@ -403,12 +393,7 @@ namespace Elwig.Windows {
|
||||
DeliveryAncmtList.IsEnabled = true;
|
||||
|
||||
using var ctx = new AppDbContext();
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.Where(m => m.IsActive || !IsCreating)
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !IsCreating).ToListAsync());
|
||||
|
||||
HideSaveResetCancelButtons();
|
||||
ShowNewEditDeleteButtons();
|
||||
|
||||
@@ -105,14 +105,14 @@ namespace Elwig.Windows {
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
await base.OnRenewContext(ctx);
|
||||
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.Branches.OrderBy(b => b.Name).ToListAsync());
|
||||
var varieties = await ctx.WineVarieties.OrderBy(v => v.Name).ToListAsync();
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.FetchBranches().ToListAsync());
|
||||
var varieties = await ctx.FetchWineVarieties().ToListAsync();
|
||||
ControlUtils.RenewItemsSource(MainWineVarietiesInput, varieties);
|
||||
ControlUtils.RenewItemsSource(OtherWineVarietiesInput, varieties);
|
||||
var attrList = await ctx.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
var attrList = await ctx.FetchWineAttributes().Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem("- Keine Angabe -"));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
|
||||
var cultList = await ctx.WineCultivations.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
var cultList = await ctx.FetchWineCultivations().Cast<object>().ToListAsync();
|
||||
cultList.Insert(0, new NullItem("- Kein Angabe -"));
|
||||
ControlUtils.RenewItemsSource(CultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Elwig.Windows {
|
||||
public MailWindow(int? year = null) {
|
||||
InitializeComponent();
|
||||
using (var ctx = new AppDbContext()) {
|
||||
Year = year ?? ctx.Seasons.OrderBy(s => s.Year).LastOrDefault()?.Year ?? Utils.Today.Year;
|
||||
Year = year ?? ctx.Seasons.OrderByDescending(s => s.Year).FirstOrDefault()?.Year ?? Utils.Today.Year;
|
||||
Title = $"Rundschreiben - Lese {Year} - Elwig";
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
var season = await ctx.Seasons.Include(s => s.PaymentVariants).SingleAsync(s => s.Year == Year);
|
||||
var season = await ctx.Seasons.Include(s => s.PaymentVariants).Where(s => s.Year == Year).SingleAsync();
|
||||
var l = new List<string> {
|
||||
MemberDataSheet.Name
|
||||
};
|
||||
@@ -165,10 +165,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
AvaiableDocumentsList.ItemsSource = l;
|
||||
|
||||
ControlUtils.RenewItemsSource(MemberBranchInput, await ctx.Branches
|
||||
.Where(b => b.Members.Count != 0)
|
||||
.OrderBy(b => b.Name)
|
||||
.ToListAsync(), MemberInput_SelectionChanged);
|
||||
ControlUtils.RenewItemsSource(MemberBranchInput, await ctx.FetchBranches(includeWithoutMembers: false).ToListAsync(), MemberInput_SelectionChanged);
|
||||
if (MemberBranchInput.SelectedItems.Count == 0) {
|
||||
MemberBranchInput.SelectionChanged -= MemberInput_SelectionChanged;
|
||||
MemberBranchInput.SelectAll();
|
||||
@@ -368,7 +365,7 @@ namespace Elwig.Windows {
|
||||
RecipientsDeliveryMembersInput.IsChecked = true;
|
||||
} else if (idx >= 2) {
|
||||
var name = s.Split(" – ")[^1];
|
||||
var pv = await ctx.PaymentVariants.SingleAsync(v => v.Year == Year && v.Name == name)!;
|
||||
var pv = await ctx.PaymentVariants.Where(v => v.Year == Year && v.Name == name).SingleAsync();
|
||||
SelectedDocs.Add(new(DocType.CreditNote, s, (pv.Year, pv.AvNr)));
|
||||
RecipientsCreditMembersInput.IsChecked = true;
|
||||
}
|
||||
@@ -715,7 +712,7 @@ namespace Elwig.Windows {
|
||||
foreach (var doc in docs) {
|
||||
if (doc.Type == DocType.DeliveryConfirmation) {
|
||||
var year = (int)doc.Details!;
|
||||
var b = new Billing(year);
|
||||
var b = await Billing.Create(year);
|
||||
await b.FinishSeason();
|
||||
await b.CalculateBuckets();
|
||||
App.HintContextChange();
|
||||
@@ -997,7 +994,7 @@ namespace Elwig.Windows {
|
||||
return;
|
||||
var name = s.Split(" – ")[^1];
|
||||
using var ctx = new AppDbContext();
|
||||
var pv = ctx.PaymentVariants.Single(v => v.Year == Year && v.Name == name)!;
|
||||
var pv = ctx.PaymentVariants.Where(v => v.Year == Year && v.Name == name).Single();
|
||||
SelectedDocs.Add(new(DocType.CreditNote, s, (pv.Year, pv.AvNr)));
|
||||
SelectedDocumentsList.SelectedIndex = SelectedDocs.Count - 1;
|
||||
RecipientsCreditMembersInput.IsChecked = true;
|
||||
|
||||
@@ -404,7 +404,7 @@ namespace Elwig.Windows {
|
||||
private async void SeasonInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
|
||||
using var ctx = new AppDbContext();
|
||||
var year = SeasonInput.Value;
|
||||
var s0 = await ctx.Seasons.FindAsync(year);
|
||||
var s0 = await ctx.FetchSeasons(year).SingleOrDefaultAsync();
|
||||
var valid = (s0 != null);
|
||||
DeliveryConfirmationButton.IsEnabled = valid;
|
||||
PaymentButton.IsEnabled = valid;
|
||||
@@ -468,7 +468,7 @@ namespace Elwig.Windows {
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
await Task.Run(async () => {
|
||||
try {
|
||||
var b = new Billing(year);
|
||||
var b = await Billing.Create(year);
|
||||
await b.FinishSeason();
|
||||
await b.CalculateBuckets();
|
||||
App.HintContextChange();
|
||||
@@ -501,7 +501,7 @@ namespace Elwig.Windows {
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
await Task.Run(async () => {
|
||||
try {
|
||||
var b = new Billing(year);
|
||||
var b = await Billing.Create(year);
|
||||
await b.FinishSeason();
|
||||
await b.CalculateBuckets();
|
||||
App.HintContextChange();
|
||||
@@ -510,7 +510,7 @@ namespace Elwig.Windows {
|
||||
using var ods = new OdsFile(d.FileName);
|
||||
var tblTotal = await WeightBreakdownData.ForSeason(ctx.WeightBreakDownRows, year);
|
||||
await ods.AddTable(tblTotal);
|
||||
foreach (var branch in await ctx.Branches.OrderBy(b => b.Name).ToListAsync()) {
|
||||
foreach (var branch in await ctx.FetchBranches().ToListAsync()) {
|
||||
var tbl = await WeightBreakdownData.ForSeason(ctx.WeightBreakDownRows, year, branch);
|
||||
await ods.AddTable(tbl);
|
||||
}
|
||||
@@ -536,7 +536,7 @@ namespace Elwig.Windows {
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
await Task.Run(async () => {
|
||||
try {
|
||||
var b = new Billing(year);
|
||||
var b = await Billing.Create(year);
|
||||
await b.FinishSeason();
|
||||
await b.CalculateBuckets();
|
||||
App.HintContextChange();
|
||||
@@ -567,7 +567,7 @@ namespace Elwig.Windows {
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
await Task.Run(async () => {
|
||||
try {
|
||||
var b = new Billing(year);
|
||||
var b = await Billing.Create(year);
|
||||
await b.FinishSeason();
|
||||
await b.CalculateBuckets();
|
||||
App.HintContextChange();
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace Elwig.Windows {
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
await base.OnRenewContext(ctx);
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.Branches.OrderBy(b => b.Name).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.FetchBranches().ToListAsync());
|
||||
ControlUtils.RenewItemsSource(DefaultKgInput, await ctx.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync());
|
||||
|
||||
var font = new System.Windows.Media.FontFamily("Segoe MDL2 Assets");
|
||||
@@ -391,7 +391,7 @@ namespace Elwig.Windows {
|
||||
|
||||
int areaComs = 0, deliveries = 0, credits = 0;
|
||||
using (var ctx = new AppDbContext()) {
|
||||
var l = (await ctx.Members.FindAsync(m.MgNr))!;
|
||||
var l = await ctx.FetchMembers(m.MgNr).SingleAsync();
|
||||
areaComs = l.AreaCommitments.Count;
|
||||
deliveries = l.Deliveries.Count;
|
||||
credits = l.Credits.Count;
|
||||
@@ -796,7 +796,7 @@ namespace Elwig.Windows {
|
||||
if (areaComs.Count == 0)
|
||||
return;
|
||||
|
||||
var oldMember = (await ctx.Members.FindAsync(mgnr))!;
|
||||
var oldMember = await ctx.FetchMembers(mgnr).SingleAsync();
|
||||
var newName = $"{ViewModel.Name?.Replace('ß', 'ẞ').ToUpper()} " +
|
||||
$"{ViewModel.Prefix}{(!string.IsNullOrEmpty(ViewModel.Prefix) ? " " : "")}" +
|
||||
$"{ViewModel.GivenName}{(!string.IsNullOrEmpty(ViewModel.GivenName) ? " " : "")}" +
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
var members = await ctx.Members
|
||||
var members = await ctx.FetchMembers(includeNotActive: true)
|
||||
.Select(m => new {
|
||||
m.MgNr,
|
||||
m.Name,
|
||||
@@ -48,11 +48,8 @@ namespace Elwig.Windows {
|
||||
m.BusinessShares,
|
||||
m.IsActive,
|
||||
})
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToListAsync();
|
||||
var season = (await ctx.Seasons.FindAsync(Year))!;
|
||||
var season = await ctx.FetchSeasons(Year).SingleAsync();
|
||||
var contracts = await ctx.AreaCommitmentTypes.ToDictionaryAsync(t => t.VtrgId, t => t);
|
||||
|
||||
var tbl1 = await OverUnderDeliveryData.ForSeason(ctx.OverUnderDeliveryRows, Year);
|
||||
@@ -145,11 +142,7 @@ namespace Elwig.Windows {
|
||||
TotalModifiers.Text = $"{list.Count(r => r.Total != 0)} Mg. / {list.Sum(r => r.Total):N2} {sym}";
|
||||
NonDeliveries.Text = $"{list.Count(r => r.Weight == 0):N0}";
|
||||
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
|
||||
.OrderBy(m => m.Name)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToListAsync());
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: true).ToListAsync());
|
||||
CustomAmountInput.Unit = sym;
|
||||
}
|
||||
|
||||
@@ -170,7 +163,7 @@ namespace Elwig.Windows {
|
||||
|
||||
await Task.Run(async () => {
|
||||
await App.Client.UpdateValues();
|
||||
var b = new Billing(Year);
|
||||
var b = await Billing.Create(Year);
|
||||
await b.AutoAdjustBusinessShares(new DateOnly(Year, 11, 30), kg ?? default, bs ?? default, kgPerBs ?? default, percent / 100.0 ?? default, minBs ?? default);
|
||||
});
|
||||
App.HintContextChange();
|
||||
@@ -186,7 +179,7 @@ namespace Elwig.Windows {
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
try {
|
||||
await Task.Run(async () => {
|
||||
var b = new Billing(Year);
|
||||
var b = await Billing.Create(Year);
|
||||
await b.UnAdjustBusinessShares();
|
||||
});
|
||||
App.HintContextChange();
|
||||
|
||||
Reference in New Issue
Block a user