@code { @using HyperCube.Models; [Inject] public IJSRuntime JsRuntime { get; set; } [Parameter] public RenderFragment Title { get; set; } [Parameter] public RenderFragment Body { get; set; } string message = ""; string elementid = "modal_notifications"; Dictionary _notifications = new(); AccountModel _currentAcc = new(); public async Task SendTestNotification() { await _currentAcc.SendTestNotification(_currentAcc, "Test text"); } public void Open(Dictionary notifications, AccountModel acc) { _notifications = acc.notifications; _currentAcc = acc; JsRuntime.InvokeVoidAsync("OpenModal", elementid); } public void Close() { JsRuntime.InvokeVoidAsync("CloseModal", elementid); } async Task ReadOnClick(int id) { if (!_notifications[id].IsRead) { _notifications[id].IsRead = true; _notifications[id].DateRead = DateTime.Now; } else { _notifications[id].IsRead = false; _notifications[id].DateRead = null; } await _notifications[id].Update(); } async Task ApproveOnClick(int id) { if (!_notifications[id].IsApproved) { _notifications[id].IsApproved = true; _notifications[id].DateApprove = DateTime.Now; } else { _notifications[id].IsApproved = false; _notifications[id].DateApprove = null; } await _notifications[id].Update(); } async Task RejectOnClick(int id) { if (!_notifications[id].IsRejected) { _notifications[id].IsRejected = true; _notifications[id].DateReject = DateTime.Now; } else { _notifications[id].IsRejected = false; _notifications[id].DateReject = null; } await _notifications[id].Update(); } }