[#29] DeliveryAdminWindow: Only show sums of filtered parts when filtering
This commit is contained in:
@ -68,19 +68,32 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[InverseProperty("Delivery")]
|
||||
public virtual ISet<DeliveryPart> Parts { get; private set; }
|
||||
[NotMapped]
|
||||
public IEnumerable<DeliveryPart> FilteredParts => PartFilter == null ? Parts : Parts.Where(p => PartFilter(p));
|
||||
|
||||
[NotMapped]
|
||||
public Predicate<DeliveryPart>? PartFilter { get; set; }
|
||||
|
||||
public int Weight => Parts.Select(p => p.Weight).Sum();
|
||||
public int FilteredWeight => FilteredParts.Select(p => p.Weight).Sum();
|
||||
|
||||
public IEnumerable<string> SortIds => Parts
|
||||
.GroupBy(p => p.SortId)
|
||||
.OrderByDescending(g => g.Select(p => p.Weight).Sum())
|
||||
.Select(g => g.Select(p => p.SortId).First());
|
||||
.Select(g => g.Key);
|
||||
public IEnumerable<string> FilteredSortIds => FilteredParts
|
||||
.GroupBy(p => p.SortId)
|
||||
.OrderByDescending(g => g.Select(p => p.Weight).Sum())
|
||||
.Select(g => g.Key);
|
||||
|
||||
public string SortIdString => string.Join(", ", SortIds);
|
||||
public string FilteredSortIdString => string.Join(", ", FilteredSortIds);
|
||||
|
||||
public double Kmw => Utils.AggregateDeliveryPartsKmw(Parts);
|
||||
public double FilteredKmw => Utils.AggregateDeliveryPartsKmw(FilteredParts);
|
||||
|
||||
public double Oe => Utils.KmwToOe(Kmw);
|
||||
public double FilteredOe => Utils.KmwToOe(FilteredKmw);
|
||||
|
||||
public int SearchScore(IEnumerable<string> keywords) {
|
||||
var list = new string?[] {
|
||||
|
Reference in New Issue
Block a user