[#57] AreaComAdminWindow: Use Task.Run()
This commit is contained in:
@ -108,7 +108,8 @@ namespace Elwig.Services {
|
||||
public static async Task<int> UpdateAreaCommitment(this AreaComAdminViewModel vm, int? oldFbNr) {
|
||||
int newFbNr = (int)vm.FbNr!;
|
||||
|
||||
using (var ctx = new AppDbContext()) {
|
||||
await Task.Run(async () => {
|
||||
using var ctx = new AppDbContext();
|
||||
var a = new AreaCom {
|
||||
FbNr = oldFbNr ?? newFbNr,
|
||||
MgNr = (int)vm.MgNr!,
|
||||
@ -140,7 +141,7 @@ namespace Elwig.Services {
|
||||
if (newFbNr != a.FbNr) {
|
||||
await ctx.Database.ExecuteSqlAsync($"UPDATE area_commitment SET fbnr = {newFbNr} WHERE fbnr = {oldFbNr}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
App.HintContextChange();
|
||||
|
||||
@ -253,5 +254,16 @@ namespace Elwig.Services {
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
|
||||
public static async Task DeleteAreaCom(int fbnr) {
|
||||
await Task.Run(async () => {
|
||||
using var ctx = new AppDbContext();
|
||||
var l = (await ctx.AreaCommitments.FindAsync(fbnr))!;
|
||||
ctx.Remove(l);
|
||||
await ctx.SaveChangesAsync();
|
||||
});
|
||||
|
||||
App.HintContextChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user