blazor-calendar/BlazorApp/Pages/Calendar.razor

56 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2021-07-03 12:19:53 +00:00
@page "/calendars/{id:int}"
@inject Data.CalendarService _calendarService
2021-07-04 11:38:52 +00:00
<a href="/">
<span class="oi oi-arrow-left"></span> Back
</a>
2021-07-03 12:19:53 +00:00
@if (_calendar == null || _events == null)
{
<p>
<em>Loading...</em>
</p>
}
else
{
<h1>Calendar "@_calendar.Name"</h1>
@foreach (var @event in _events)
2021-07-03 12:19:53 +00:00
{
<div class="event">
<a href="/calendars/@Id/events/@(@event.Uid)">
<h2>@(@event.Summary)</h2>
2021-07-03 12:19:53 +00:00
</a>
@if (@event.DtStart != null)
{
<div>
<strong>Start:</strong> @(@event.DtStart)
</div>
}
2021-07-04 12:36:21 +00:00
@if (@event.CalculatedEnd != null)
{
<div>
2021-07-04 12:36:21 +00:00
<strong>End:</strong> @(@event.CalculatedEnd)
</div>
}
<div class="event-description-short">@(@event.Description)</div>
2021-07-03 12:19:53 +00:00
</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();
}
}