Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AccountEventItem.cs
5
7{
15 public class AccountEventItem(EDaler.AccountEvent AccountEvent, MyWalletViewModel ViewModel, string FriendlyName, NotificationEvent[] NotificationEvents) : IUniqueItem
16 {
17 private readonly EDaler.AccountEvent accountEvent = AccountEvent;
18 private readonly MyWalletViewModel viewModel = ViewModel;
19 private readonly string friendlyName = FriendlyName;
20 private bool? @new;
21 private NotificationEvent[] notificationEvents = NotificationEvents;
22
26 public decimal Balance => this.accountEvent.Balance;
27
31 public decimal Reserved => this.accountEvent.Reserved;
32
36 public decimal Change => this.accountEvent.Change;
37
41 public DateTime Timestamp => this.accountEvent.Timestamp;
42
46 public Guid TransactionId => this.accountEvent.TransactionId;
47
49 public string UniqueName => this.TransactionId.ToString();
50
54 public string Remote => this.accountEvent.Remote;
55
59 public string FriendlyName => this.friendlyName;
60
64 public string Message => this.accountEvent.Message;
65
69 public bool HasMessage => !string.IsNullOrEmpty(this.accountEvent.Message);
70
74 public string? Currency => this.viewModel.Currency;
75
79 public NotificationEvent[] NotificationEvents => this.notificationEvents;
80
84 public bool New
85 {
86 get
87 {
88 if (!this.@new.HasValue)
89 {
90 this.@new = this.notificationEvents.Length > 0;
91 if (this.@new.Value)
92 {
93 NotificationEvent[] ToDelete = this.notificationEvents;
94
95 this.notificationEvents = [];
96
97 Task.Run(() => ServiceRef.NotificationService.DeleteEvents(ToDelete));
98 }
99 }
100
101 return this.@new.Value;
102 }
103 }
104
108 public Color? TextColor
109 {
110 get
111 {
112 if (this.Change >= 0)
114 else
115 return AppColors.Alert;
116 }
117 }
118
122 public string TimestampStr
123 {
124 get
125 {
126 DateTime Today = DateTime.Today;
127
128 if (this.Timestamp.Date == Today)
129 return this.Timestamp.ToLongTimeString();
130 else if (this.Timestamp.Date == Today.AddDays(-1))
131 return ServiceRef.Localizer[nameof(AppResources.Yesterday)] + ", " + this.Timestamp.ToLongTimeString();
132 else
133 return this.Timestamp.ToShortDateString() + ", " + this.Timestamp.ToLongTimeString();
134 }
135 }
136
140 public string ReservedSuffix
141 {
142 get
143 {
144 if (this.accountEvent.Reserved == 0)
145 return string.Empty;
146
147 return "+" + MoneyToString.ToString(this.accountEvent.Reserved);
148 }
149 }
150 }
151}
Account event
Definition: AccountEvent.cs:16
Base class that references services in the app.
Definition: ServiceRef.cs:31
static INotificationService NotificationService
Service for managing notifications for the user.
Definition: ServiceRef.cs:211
static IStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:235
Static class that gives access to app-specific themed colors
Definition: AppColors.cs:7
static Color PrimaryForeground
Primary foreground color.
Definition: AppColors.cs:62
static Color Alert
Alert color.
Definition: AppColors.cs:442
static string ToString(decimal Money)
Converts a monetary value to a string, removing any round-off errors.
Task DeleteEvents(NotificationEventType Type, CaseInsensitiveString Category)
Deletes events for a given button and category.
abstract class NotificationEvent()
Abstract base class of notification events.
partial class MyWalletViewModel(WalletNavigationArgs? Args)
The view model to bind to for when displaying the wallet.