From dfd66c9fb69fa981b635d642718f38c623b085e3 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Wed, 4 Aug 2021 17:39:57 +0200 Subject: [PATCH] capitalise bounty voucher type --- BGS/Vouchers.cs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/BGS/Vouchers.cs b/BGS/Vouchers.cs index b9c7f41..f7b92bf 100644 --- a/BGS/Vouchers.cs +++ b/BGS/Vouchers.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; +using System.Globalization; using NonaBGS.Journal; namespace NonaBGS.BGS { public class Vouchers : LogEntry { + private string type = null; public int TotalSum { get { @@ -19,21 +17,21 @@ namespace NonaBGS.BGS { public string Type { get { - string v = Entries - .Where(x => x.GetType() == typeof(RedeemVoucherEntry)) - .GroupBy(x => (x as RedeemVoucherEntry).Type) - .Select(x => x.Key) - .First(); - return v; + if (type == null) { + string v = Entries + .Where(x => x.GetType() == typeof(RedeemVoucherEntry)) + .GroupBy(x => (x as RedeemVoucherEntry).Type) + .Select(x => x.Key) + .First(); + type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v); + } + + return type; } } public override string ToString() { - StringBuilder builder = new StringBuilder(); - - builder.AppendFormat("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum)); - - return builder.ToString(); + return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum)); } ///