add DateTime property variant for CompletedAt

This commit is contained in:
Florian Stinglmayr 2022-12-09 17:51:46 +01:00
parent bf43262a8e
commit a3b54b1326
4 changed files with 20 additions and 14 deletions

View File

@ -21,12 +21,12 @@ public class InfluenceSupport : Transaction {
/// </summary>
public MissionAcceptedEntry? AcceptedEntry { get; set; }
public override string CompletedAt {
public override DateTime? CompletedAtDateTime {
get {
if (RelevantMission == null) {
return "";
return null;
}
return RelevantMission.Timestamp.ToString("dd.MM.yyyy hh:mm UTC");
return RelevantMission.Timestamp;
}
}

View File

@ -11,12 +11,12 @@ public class MissionCompleted : Transaction {
public MissionCompleted() { }
public override string CompletedAt {
public override DateTime? CompletedAtDateTime {
get {
if (CompletedEntry == null) {
return "";
return null;
}
return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
return CompletedEntry.Timestamp;
}
}

View File

@ -1,9 +1,4 @@
using EDPlayerJournal.Entries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EDPlayerJournal.BGS;

View File

@ -6,18 +6,29 @@ namespace EDPlayerJournal.BGS;
public class Transaction : IComparable<Transaction> {
public List<Entry> Entries { get; } = new List<Entry>();
public virtual string CompletedAt {
public string CompletedAt {
get {
DateTime? datetime = CompletedAtDateTime;
if (datetime == null) {
return "Unknown";
}
return datetime.Value.ToString("dd.MM.yyyy HH:mm UTC");
}
}
public virtual DateTime? CompletedAtDateTime {
get {
var items = Entries
.OrderBy(x => x.Timestamp)
.ToArray()
;
if (items == null || items.Length == 0) {
return "Unknown";
return null;
}
Entry last = items.Last();
return last.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
return last.Timestamp;
}
}