[#14] Documents: Add DeliveryAncmtList
All checks were successful
Test / Run tests (push) Successful in 2m35s
All checks were successful
Test / Run tests (push) Successful in 2m35s
This commit is contained in:
62
Elwig/Models/Dtos/DeliveryAncmtListData.cs
Normal file
62
Elwig/Models/Dtos/DeliveryAncmtListData.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using Elwig.Documents;
|
||||
using Elwig.Models.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elwig.Models.Dtos {
|
||||
public class DeliveryAncmtListData : DataTable<DeliveryAncmtListRow> {
|
||||
|
||||
private static readonly (string, string, string?, int?)[] FieldNames = [
|
||||
("Date", "Datum", null, 20),
|
||||
("Branch", "Zweigstelle", null, 30),
|
||||
("MgNr", "MgNr.", null, 12),
|
||||
("Name1", "Name", null, 40),
|
||||
("Name2", "Vorname", null, 40),
|
||||
("SortId", "Sorte", null, 10),
|
||||
("Weight", "Gewicht", "kg", 20),
|
||||
];
|
||||
|
||||
public DeliveryAncmtListData(IEnumerable<DeliveryAncmtListRow> rows, List<string> filterNames) :
|
||||
base(DeliveryAncmtList.Name, DeliveryAncmtList.Name, string.Join(" / ", filterNames), rows, FieldNames) {
|
||||
}
|
||||
|
||||
public static async Task<DeliveryAncmtListData> FromQuery(IQueryable<DeliveryAncmt> query, List<string> filterNames) {
|
||||
return new((await query
|
||||
.Include(a => a.Schedule.Branch)
|
||||
.Include(a => a.Member)
|
||||
.Include(a => a.Variety)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync()).Select(d => new DeliveryAncmtListRow(d)), filterNames);
|
||||
}
|
||||
}
|
||||
|
||||
public class DeliveryAncmtListRow {
|
||||
public DateOnly Date;
|
||||
public string Branch;
|
||||
public int MgNr;
|
||||
public string Name1;
|
||||
public string Name2;
|
||||
public string AdministrativeName;
|
||||
public string SortId;
|
||||
public string Variety;
|
||||
public int Weight;
|
||||
|
||||
public DeliveryAncmtListRow(DeliveryAncmt a) {
|
||||
var s = a.Schedule;
|
||||
var m = a.Member;
|
||||
|
||||
Date = s.Date;
|
||||
Branch = s.Branch.Name;
|
||||
MgNr = m.MgNr;
|
||||
Name1 = m.AdministrativeName1;
|
||||
Name2 = m.AdministrativeName2;
|
||||
AdministrativeName = m.AdministrativeName;
|
||||
SortId = a.SortId;
|
||||
Variety = a.Variety.Name;
|
||||
Weight = a.Weight;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user