@page "/"
@using BlazorApp.Data
@inject CalendarService _calendarService
@if (_calendars == null)
{
Loading...
}
else
{
Calendars
@if (_calendarModel != null)
{
Add New Calendar
}
else
{
}
}
@code
{
private List _calendars;
private int? _confirmDeleteId = null;
private Data.Calendar _calendarModel = null;
protected override async Task OnInitializedAsync()
{
_calendars = await CalendarService.GetCalendars();
}
private void ShowAddCalendar()
{
_calendarModel = new Data.Calendar();
}
private async Task HandleValidSubmit()
{
await CalendarService.CreateCalendar(_calendarModel);
_calendarModel = null;
_calendars = await CalendarService.GetCalendars();
}
private async Task DeleteCalendar(Data.Calendar calendar)
{
if (_confirmDeleteId != calendar.Id)
{
_confirmDeleteId = calendar.Id;
return;
}
await CalendarService.DeleteCalendar(calendar);
_calendars = await CalendarService.GetCalendars();
_confirmDeleteId = null;
}
}