blazor-calendar/BlazorApp/Pages/Calendar.razor

44 lines
971 B
Plaintext

@page "/calendars/{id:int}"
@inject Data.CalendarService _calendarService
@if (_calendar == null || _events == null)
{
<p>
<em>Loading...</em>
</p>
}
else
{
<h1>Calendar "@_calendar.Name"</h1>
@foreach (var e in _events)
{
<div class="event">
<a href="/calendars/@Id/events/@e.Uid">
<h2>@e.Summary</h2>
</a>
<div>
<strong>Start:</strong> @e.DtStart
</div>
<div>
<strong>End:</strong> @e.DtEnd
</div>
<div class="event-description-short">@e.Description</div>
</div>
}
}
@code
{
[Parameter]
public int Id { get; set; }
private Data.Calendar _calendar;
private List<Data.Event> _events;
protected override async Task OnInitializedAsync()
{
_calendar = await Data.CalendarService.GetCalendarById(Id);
_events = await _calendar.GetEvents();
}
}