42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Elwig.Helpers.Billing {
|
|
public class BillingVariant : Billing {
|
|
|
|
private readonly int AvNr;
|
|
|
|
public BillingVariant(int year, int avnr) : base(year) {
|
|
AvNr = avnr;
|
|
}
|
|
|
|
protected async Task DeleteInDb() {
|
|
using var cnx = await AppDbContext.ConnectAsync();
|
|
using (var cmd = cnx.CreateCommand()) {
|
|
cmd.CommandText = $"DELETE FROM payment_delivery_part WHERE (year, avnr) = ({Year}, {AvNr})";
|
|
await cmd.ExecuteNonQueryAsync();
|
|
}
|
|
using (var cmd = cnx.CreateCommand()) {
|
|
cmd.CommandText = $"DELETE FROM payment_member WHERE (year, avnr) = ({Year}, {AvNr})";
|
|
await cmd.ExecuteNonQueryAsync();
|
|
}
|
|
}
|
|
|
|
public async Task CalculatePrices() {
|
|
await DeleteInDb();
|
|
var tasks = new List<Task>();
|
|
foreach (var mgnr in Context.Members.Select(m => m.MgNr)) {
|
|
tasks.Add(Task.Run(() => CalculateMemberPrices(mgnr)));
|
|
}
|
|
await Task.WhenAll(tasks);
|
|
}
|
|
|
|
protected async Task CalculateMemberPrices(int mgnr) {
|
|
|
|
}
|
|
}
|
|
}
|