Services: Move App.HintContextChange() to Windows
Some checks failed
Test / Run tests (push) Has been cancelled

This commit is contained in:
2025-07-09 16:07:47 +02:00
parent 53d82604a1
commit 7e9a27c75d
13 changed files with 53 additions and 72 deletions

View File

@ -108,7 +108,7 @@ namespace Elwig.Services {
public static async Task<int> UpdateAreaCommitment(this AreaComAdminViewModel vm, int? oldFbNr) {
int newFbNr = (int)vm.FbNr!;
await Task.Run(async () => {
return await Task.Run(async () => {
using var ctx = new AppDbContext();
var a = new AreaCom {
FbNr = oldFbNr ?? newFbNr,
@ -141,11 +141,9 @@ namespace Elwig.Services {
if (newFbNr != a.FbNr) {
await ctx.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {oldFbNr}");
}
return newFbNr;
});
App.HintContextChange();
return newFbNr;
}
private static void AddToolTipCell(Grid grid, string text, int row, int col, int colSpan = 1, bool bold = false, bool alignRight = false, bool alignCenter = false) {
@ -262,8 +260,6 @@ namespace Elwig.Services {
ctx.Remove(l);
await ctx.SaveChangesAsync();
});
App.HintContextChange();
}
}
}

View File

@ -211,7 +211,7 @@ namespace Elwig.Services {
int newMgNr = vm.MgNr!.Value;
string newSortId = vm.SortId!;
await Task.Run(async () => {
return await Task.Run(async () => {
using var ctx = new AppDbContext();
var a = new DeliveryAncmt {
Year = oldYear ?? year,
@ -233,11 +233,9 @@ namespace Elwig.Services {
if (oldDsNr != null && (oldYear != year || oldDsNr != dsnr || oldMgNr != newMgNr || oldSortId != newSortId)) {
await ctx.Database.ExecuteSqlAsync($"UPDATE delivery_announcement SET year = {year}, dsnr = {dsnr}, mgnr = {newMgNr}, sortid = {newSortId} WHERE (year, dsnr, mgnr, sortid) = ({a.Year}, {a.DsNr}, {a.MgNr}, {a.SortId})");
}
return (year, dsnr, newMgNr, newSortId);
});
App.HintContextChange();
return (year, dsnr, newMgNr, newSortId);
}
public static async Task GenerateDeliveryAncmtList(this DeliveryAncmtAdminViewModel vm, ExportSubject subject, ExportMode mode) {

View File

@ -183,8 +183,6 @@ namespace Elwig.Services {
await ctx.SaveChangesAsync();
});
App.HintContextChange();
}
}
}

View File

@ -430,7 +430,7 @@ namespace Elwig.Services {
}
public static async Task<DeliveryPart> UpdateDeliveryPart(this DeliveryAdminViewModel vm, int? oldYear, int? oldDid, int? oldDpnr, bool dateHasChanged, bool timeHasChanged, bool timeIsDefault) {
var p = await Task.Run(async () => {
return await Task.Run(async () => {
DeliveryPart p;
using var ctx = new AppDbContext();
@ -528,14 +528,10 @@ namespace Elwig.Services {
return p;
});
App.HintContextChange();
return p;
}
public static async Task<Delivery> SplitDeliveryToMember(int year, int did, int[] weights, int mgnr) {
var n = await Task.Run(async () => {
return await Task.Run(async () => {
Delivery n;
using var ctx = new AppDbContext();
@ -584,14 +580,10 @@ namespace Elwig.Services {
return n;
});
App.HintContextChange();
return n;
}
public static async Task<Delivery> SplitDeliveryToLsNr(int year, int did, int[] weights, string lsnr) {
var n = await Task.Run(async () => {
return await Task.Run(async () => {
Delivery n;
using var ctx = new AppDbContext();
var anyLeft = false;
@ -625,10 +617,6 @@ namespace Elwig.Services {
return n;
});
App.HintContextChange();
return n;
}
public static async Task DepreciateDelivery(int year, int did, int[] weights) {
@ -658,8 +646,6 @@ namespace Elwig.Services {
}
await ctx.SaveChangesAsync();
});
App.HintContextChange();
}
public static async Task GenerateDeliveryNote(int year, int did, ExportMode mode) {
@ -1102,8 +1088,6 @@ namespace Elwig.Services {
await ctx.Deliveries.Where(d => d.LsNr == lsnr).ExecuteDeleteAsync();
await ctx.SaveChangesAsync();
});
App.HintContextChange();
}
}
}

View File

@ -611,7 +611,7 @@ namespace Elwig.Services {
ContactViaEmail = vm.ContactViaEmail,
};
await Task.Run(async () => {
return await Task.Run(async () => {
using var ctx = new AppDbContext();
if (oldMgNr != null) {
ctx.Update(m);
@ -695,11 +695,9 @@ namespace Elwig.Services {
if (newMgNr != m.MgNr) {
await ctx.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {oldMgNr}");
}
return newMgNr;
});
App.HintContextChange();
return newMgNr;
}
public static async Task DeleteMember(int mgnr, bool deletePaymentData, bool deleteDeliveries, bool deleteAreaComs) {
@ -718,8 +716,6 @@ namespace Elwig.Services {
ctx.Remove(l);
await ctx.SaveChangesAsync();
});
App.HintContextChange();
}
}
}

View File

@ -287,8 +287,7 @@ namespace Elwig.Services {
}
public static async Task<PaymentVar> CreatePaymentVariant(int year) {
Mouse.OverrideCursor = Cursors.Wait;
var v = await Task.Run(async () => {
return await Task.Run(async () => {
using var ctx = new AppDbContext();
var v = new PaymentVar {
Year = year,
@ -302,13 +301,10 @@ namespace Elwig.Services {
await ctx.SaveChangesAsync();
return v;
});
App.HintContextChange();
Mouse.OverrideCursor = null;
return v;
}
public static async Task<PaymentVar> Duplicate(this PaymentVar orig) {
var n = await Task.Run(async () => {
return await Task.Run(async () => {
using var ctx = new AppDbContext();
var n = new PaymentVar {
Year = orig.Year,
@ -322,8 +318,6 @@ namespace Elwig.Services {
await ctx.SaveChangesAsync();
return n;
});
App.HintContextChange();
return n;
}
public static async Task<(int, int)> UpdatePaymentVariant(this PaymentVariantsViewModel vm, int? oldYear, int? oldAvNr) {
@ -357,7 +351,6 @@ namespace Elwig.Services {
await ctx.SaveChangesAsync();
});
vm.WeightModifierChanged = false;
App.HintContextChange();
return (year, avnr);
}
@ -368,7 +361,6 @@ namespace Elwig.Services {
ctx.Remove(v);
await ctx.SaveChangesAsync();
});
App.HintContextChange();
}
public static async Task Calculate(int year, int avnr) {
@ -376,7 +368,6 @@ namespace Elwig.Services {
var b = new BillingVariant(year, avnr);
await b.Calculate();
});
App.HintContextChange();
}
public static async Task Commit(int year, int avnr) {
@ -384,7 +375,6 @@ namespace Elwig.Services {
var b = new BillingVariant(year, avnr);
await b.Commit();
});
App.HintContextChange();
}
public static async Task Revert(int year, int avnr) {
@ -392,7 +382,6 @@ namespace Elwig.Services {
var b = new BillingVariant(year, avnr);
await b.Revert();
});
App.HintContextChange();
}
}
}