78 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace Elwig.Helpers.Billing {
 | |
|     public class GraphEntry {
 | |
| 
 | |
|         public int Id { get; set; }
 | |
|         private readonly int Precision;
 | |
|         public BillingData.CurveMode Mode { get; set; }
 | |
|         public bool Abgewertet { get; set; }
 | |
|         public Graph DataGraph { get; set; }
 | |
|         public Graph? GebundenGraph { get; set; }
 | |
|         public decimal? GebundenFlatBonus { get; set; }
 | |
|         public List<ContractSelection> Contracts { get; set; }
 | |
|         public string ContractsStringSimple => Contracts.Any() ? string.Join(", ", Contracts.Select(c => c.Listing)) : "-";
 | |
|         public string ContractsString => Contracts.Any() ? string.Join("\n", Contracts.Select(c => c.FullName)) : "-";
 | |
|         private int MinX { get; set; }
 | |
|         private int MinXGebunden { get; set; }
 | |
|         private int MaxX { get; set; }
 | |
| 
 | |
|         public GraphEntry(int id, int precision, BillingData.CurveMode mode, int minX, int minXGebunden, int maxX) {
 | |
|             Id = id;
 | |
|             Precision = precision;
 | |
|             Mode = mode;
 | |
|             Abgewertet = false;
 | |
|             MinX = minX;
 | |
|             MinXGebunden = minXGebunden;
 | |
|             MaxX = maxX;
 | |
|             DataGraph = new Graph(precision, minX, maxX);
 | |
|             Contracts = [];
 | |
|         }
 | |
| 
 | |
|         public GraphEntry(int id, int precision, BillingData.CurveMode mode, Dictionary<double, decimal> data, Dictionary<double, decimal>? gebunden,
 | |
|             int minX, int minXGebunden, int maxX) : this(id, precision, mode, minX, minXGebunden, maxX) {
 | |
|             DataGraph = new Graph(data, precision, minX, maxX);
 | |
|             if (gebunden != null) GebundenGraph = new Graph(gebunden, precision, minXGebunden, maxX);
 | |
|         }
 | |
| 
 | |
|         public GraphEntry(int id, int precision, BillingData.Curve curve, List<ContractSelection> contracts, int minX, int minXGebunden, int maxX) :
 | |
|             this(id, precision, curve.Mode, minX, minXGebunden, maxX) {
 | |
|             DataGraph = new Graph(curve.Normal, precision, minX, maxX);
 | |
|             if (curve.Gebunden != null)
 | |
|                 GebundenGraph = new Graph(curve.Gebunden, precision, minXGebunden, maxX);
 | |
|             Contracts = contracts;
 | |
|         }
 | |
| 
 | |
|         private GraphEntry(int id, int precision, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
 | |
|             decimal? gebundenFlatPrice, List<ContractSelection> contracts, int minX, int minXGebunden, int maxX) {
 | |
|             Id = id;
 | |
|             Precision = precision;
 | |
|             Mode = mode;
 | |
|             MinX = minX;
 | |
|             MinXGebunden = minXGebunden;
 | |
|             MaxX = maxX;
 | |
|             DataGraph = dataGraph;
 | |
|             GebundenGraph = gebundenGraph;
 | |
|             GebundenFlatBonus = gebundenFlatPrice;
 | |
|             Contracts = contracts;
 | |
|         }
 | |
| 
 | |
|         public void AddGebundenGraph() {
 | |
|             GebundenGraph ??= new Graph(Precision, MinXGebunden, MaxX);
 | |
|         }
 | |
| 
 | |
|         public void RemoveGebundenGraph() {
 | |
|             GebundenGraph = null;
 | |
|         }
 | |
| 
 | |
|         public void SetGebundenFlatBonus(decimal? value) {
 | |
|             GebundenFlatBonus = value;
 | |
|         }
 | |
| 
 | |
|         public GraphEntry Copy(int id) {
 | |
|             return new GraphEntry(id, Precision, Mode, (Graph)DataGraph.Clone(), (Graph?)GebundenGraph?.Clone(), GebundenFlatBonus, [], MinX, MinXGebunden, MaxX);
 | |
|         }
 | |
|     }
 | |
| }
 |