ChartWindow: Enhance ComboCheckBox
This commit is contained in:
@ -8,40 +8,31 @@ namespace Elwig.Helpers.Billing {
|
||||
|
||||
public WineVar? Variety { get; }
|
||||
public WineAttr? Attribute { get; }
|
||||
public string Listing => Variety != null || Attribute != null ? $"{Variety?.SortId}{Attribute?.AttrId}" : "";
|
||||
public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}";
|
||||
|
||||
public ContractSelection(WineVar? var, WineAttr? attr) {
|
||||
Variety = var;
|
||||
Attribute = attr;
|
||||
}
|
||||
|
||||
public ContractSelection(WineVar var) {
|
||||
Variety = var;
|
||||
}
|
||||
|
||||
public ContractSelection(WineAttr attr) {
|
||||
Attribute = attr;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return (Variety != null ? $"{Variety.Name}" : "") + (Attribute != null ? $" {Attribute.Name}" : "");
|
||||
}
|
||||
|
||||
public static List<ContractSelection> GetContractsForYear(AppDbContext context, int year) {
|
||||
return context.DeliveryParts
|
||||
.Where(d => d.Year == year)
|
||||
.Where(p => p.Year == year)
|
||||
.Select(d => new ContractSelection(d.Variant, d.Attribute))
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Union(context.WineVarieties.Select(v => new ContractSelection(v)))
|
||||
.Union(context.WineVarieties.Select(v => new ContractSelection(v, null)))
|
||||
.DistinctBy(c => c.Listing)
|
||||
.Order()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Listing;
|
||||
}
|
||||
|
||||
public int CompareTo(ContractSelection? other) {
|
||||
//MessageBox.Show($"{Listing} -- {other.Listing} : {Listing.CompareTo(other.Listing)}");
|
||||
return other != null ?
|
||||
Listing.CompareTo(other.Listing) :
|
||||
throw new ArgumentException();
|
||||
return Listing.CompareTo(other?.Listing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user