Dtos: Add more DTOs
This commit is contained in:
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Elwig.Models.Dtos {
|
||||
public class DeliveryConfirmationData : DataTable<DeliveryConfirmationRow> {
|
||||
|
||||
private static readonly (string, string)[] _fieldNames = new[] {
|
||||
private static readonly (string, string)[] FieldNames = new[] {
|
||||
("LsNr", "LsNr."),
|
||||
("DPNr", "Pos."),
|
||||
("Variant", "Sorte"),
|
||||
@ -20,24 +20,24 @@ namespace Elwig.Models.Dtos {
|
||||
("Weight", "Gewicht"),
|
||||
};
|
||||
|
||||
public int MgNr { get; private set; }
|
||||
private readonly int MgNr;
|
||||
|
||||
private DeliveryConfirmationData(IEnumerable<DeliveryConfirmationRow> rows, int mgnr) :
|
||||
base("Anl.-Best.", "Anlieferungsbestätigung", rows, _fieldNames) {
|
||||
MgNr = mgnr;
|
||||
private DeliveryConfirmationData(IEnumerable<DeliveryConfirmationRow> rows, int year, Member m) :
|
||||
base($"Anlieferungsbestätigung", $"Anlieferungsbestätigung {year} – {m.AdministrativeName}", rows, FieldNames) {
|
||||
MgNr = m.MgNr;
|
||||
}
|
||||
|
||||
public static async Task<IDictionary<int, DeliveryConfirmationData>> ForSeason(DbSet<DeliveryPart> table, int year) {
|
||||
return (await FromDbSet(table, year))
|
||||
.GroupBy(
|
||||
p => p.Delivery.MgNr,
|
||||
p => p.Delivery.Member,
|
||||
p => new DeliveryConfirmationRow(p),
|
||||
(k, g) => new DeliveryConfirmationData(g, k)
|
||||
(k, g) => new DeliveryConfirmationData(g, year, k)
|
||||
).ToDictionary(d => d.MgNr, d => d);
|
||||
}
|
||||
|
||||
public static async Task<DeliveryConfirmationData> ForMember(DbSet<DeliveryPart> table, int year, int mgnr) {
|
||||
return new DeliveryConfirmationData((await FromDbSet(table, year, mgnr)).Select(p => new DeliveryConfirmationRow(p)), mgnr);
|
||||
public static async Task<DeliveryConfirmationData> ForMember(DbSet<DeliveryPart> table, int year, Member m) {
|
||||
return new DeliveryConfirmationData((await FromDbSet(table, year, m.MgNr)).Select(p => new DeliveryConfirmationRow(p)), year, m);
|
||||
}
|
||||
|
||||
private static async Task<IEnumerable<DeliveryPart>> FromDbSet(DbSet<DeliveryPart> table, int? year = null, int? mgnr = null) {
|
||||
@ -66,7 +66,6 @@ namespace Elwig.Models.Dtos {
|
||||
}
|
||||
|
||||
public class DeliveryConfirmationRow {
|
||||
|
||||
public string LsNr;
|
||||
public int DPNr;
|
||||
public string Variant;
|
||||
|
Reference in New Issue
Block a user