blazor-calendar/BlazorApp/Pages/Event.razor

71 lines
1.4 KiB
Plaintext

@page "/calendars/{calendarId:int}/events/{eventUid}"
@inject Data.CalendarService _calendarService
<a href="/calendars/@CalendarId">
<span class="oi oi-arrow-left"></span> Back
</a>
@if (_event == null)
{
<p>
<em>Loading...</em>
</p>
}
else
{
@if (!_editTitle)
{
<h1 class="event-summary">
<span @onclick="() => _editTitle = true">@_event.Summary</span>
</h1>
}
else
{
<input @bind="@_event.Summary">
<button @onclick="UpdateEvent">Save</button>
}
<div>
<strong>ETag:</strong> @_event.ETag
</div>
@if (_event.DtStart != null)
{
<div>
<strong>Start:</strong> @_event.DtStart
</div>
}
@if (_event.CalculatedEnd != null)
{
<div>
<strong>End:</strong> @_event.CalculatedEnd
</div>
}
<p class="event-description">@_event.Description</p>
}
@code
{
[Parameter]
public int CalendarId { get; set; }
[Parameter]
public string EventUid { get; set; }
private Data.Calendar _calendar;
private Data.Event _event;
private bool _editTitle;
protected override async Task OnInitializedAsync()
{
_calendar = await Data.CalendarService.GetCalendarById(CalendarId);
_event = await _calendar.GetEventByUid(EventUid);
}
private async void UpdateEvent()
{
_event = await _calendar.UpdateEvent(_event);
}
}