@page "/calendars/{calendarId:int}/events/{eventUid}" @inject Data.CalendarService _calendarService @inject NavigationManager _navigationManager Back @if (_event == null) {
@(_notFound ? "Event not found" : "Loading...")
} else { @if (!_editTitle) {@_event.Description
} @if (!_confirmDelete) { } else { } } @code { [Parameter] public int CalendarId { get; set; } [Parameter] public string EventUid { get; set; } private Data.Calendar _calendar; private Data.Event _event; private bool _notFound; private bool _editTitle; private bool _confirmDelete; protected override async Task OnInitializedAsync() { _calendar = await Data.CalendarService.GetCalendarById(CalendarId); _event = await _calendar.GetEventByUid(EventUid); _notFound = _event == null; } private async Task UpdateEvent() { _event = await _calendar.UpdateEvent(_event); } private async Task DeleteEvent() { if (!_confirmDelete) { _confirmDelete = true; await Task.Delay(2000); } else { await _calendar.DeleteEvent(_event); _navigationManager.NavigateTo($"/calendars/{CalendarId}"); } _confirmDelete = false; } }