ChartWindow: Added second graph for gebunden
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Elwig.Helpers.Billing {
|
||||
@ -8,8 +9,10 @@ namespace Elwig.Helpers.Billing {
|
||||
public BillingData.CurveMode Mode { get; set; }
|
||||
public Graph DataGraph { get; set; }
|
||||
public Graph? GebundenGraph { get; set; }
|
||||
public decimal? GebundenFlatPrice { get; set; }
|
||||
public List<string> Contracts { 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.ToString())) : "-";
|
||||
private int MinX { get; set; }
|
||||
private int MaxX { get; set; }
|
||||
|
||||
@ -22,9 +25,10 @@ namespace Elwig.Helpers.Billing {
|
||||
Contracts = [];
|
||||
}
|
||||
|
||||
public GraphEntry(int id, BillingData.CurveMode mode, Dictionary<double, decimal> data, int minX, int maxX) :
|
||||
this(id, mode, minX, maxX) {
|
||||
public GraphEntry(int id, BillingData.CurveMode mode, Dictionary<double, decimal> data, Dictionary<double, decimal>? gebunden,
|
||||
int minX, int maxX) : this(id, mode, minX, maxX) {
|
||||
DataGraph = new Graph(data, minX, maxX);
|
||||
if (gebunden != null) GebundenGraph = new Graph(gebunden, minX, maxX);
|
||||
}
|
||||
|
||||
public GraphEntry(int id, BillingData.Curve curve, int minX, int maxX) :
|
||||
@ -35,17 +39,29 @@ namespace Elwig.Helpers.Billing {
|
||||
}
|
||||
|
||||
private GraphEntry(int id, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
|
||||
decimal? gebundenFlatPrice, List<string> contracts, int minX, int maxX) {
|
||||
decimal? gebundenFlatPrice, List<ContractSelection> contracts, int minX, int maxX) {
|
||||
Id = id;
|
||||
Mode = mode;
|
||||
MinX = minX;
|
||||
MaxX = maxX;
|
||||
DataGraph = dataGraph;
|
||||
GebundenGraph = gebundenGraph;
|
||||
GebundenFlatPrice = gebundenFlatPrice;
|
||||
GebundenFlatBonus = gebundenFlatPrice;
|
||||
Contracts = contracts;
|
||||
}
|
||||
|
||||
public void AddGebundenGraph() {
|
||||
GebundenGraph ??= new Graph(MinX, MaxX);
|
||||
}
|
||||
|
||||
public void RemoveGebundenGraph() {
|
||||
GebundenGraph = null;
|
||||
}
|
||||
|
||||
public void SetGebundenFlatBonus(decimal? value) {
|
||||
GebundenFlatBonus = value;
|
||||
}
|
||||
|
||||
public JsonObject ToJson() {
|
||||
var curve = new JsonObject {
|
||||
["id"] = Id,
|
||||
@ -54,8 +70,8 @@ namespace Elwig.Helpers.Billing {
|
||||
|
||||
curve["data"] = DataGraph.ToJson(Mode.ToString().ToLower());
|
||||
|
||||
if (GebundenFlatPrice != null) {
|
||||
curve["geb"] = GebundenFlatPrice.ToString();
|
||||
if (GebundenFlatBonus != null) {
|
||||
curve["geb"] = GebundenFlatBonus;
|
||||
} else if (GebundenGraph != null) {
|
||||
curve["geb"] = GebundenGraph.ToJson(Mode.ToString().ToLower());
|
||||
}
|
||||
@ -64,7 +80,7 @@ namespace Elwig.Helpers.Billing {
|
||||
}
|
||||
|
||||
public GraphEntry Copy(int id) {
|
||||
return new GraphEntry(id, Mode, (Graph)DataGraph.Clone(), (Graph?)GebundenGraph?.Clone(), GebundenFlatPrice, Contracts, MinX, MaxX);
|
||||
return new GraphEntry(id, Mode, (Graph)DataGraph.Clone(), (Graph?)GebundenGraph?.Clone(), GebundenFlatBonus, [], MinX, MaxX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user