ChartWindow: Added second graph for gebunden
This commit is contained in:
47
Elwig/Helpers/Billing/ContractSelection.cs
Normal file
47
Elwig/Helpers/Billing/ContractSelection.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using Elwig.Models.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Elwig.Helpers.Billing {
|
||||
public class ContractSelection : IComparable<ContractSelection> {
|
||||
|
||||
public WineVar? Variety { get; }
|
||||
public WineAttr? Attribute { get; }
|
||||
public string Listing => Variety != null || Attribute != null ? $"{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)
|
||||
.Select(d => new ContractSelection(d.Variant, d.Attribute))
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Union(context.WineVarieties.Select(v => new ContractSelection(v)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public int CompareTo(ContractSelection? other) {
|
||||
//MessageBox.Show($"{Listing} -- {other.Listing} : {Listing.CompareTo(other.Listing)}");
|
||||
return other != null ?
|
||||
Listing.CompareTo(other.Listing) :
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user