using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; namespace BlazorApp.Data { public class CalendarService { public static async Task> GetCalendars() { await using var context = new MyContext(); return await context.Calendars.ToListAsync(); } public static async Task GetCalendarById(int id) { await using var context = new MyContext(); return await context.Calendars.FindAsync(id); } public static async Task CreateCalendar(Calendar calendar) { await using var context = new MyContext(); await context.Calendars.AddAsync(calendar); await context.SaveChangesAsync(); } public static async Task DeleteCalendar(Calendar calendar) { await using var context = new MyContext(); context.Calendars.Remove(calendar); await context.SaveChangesAsync(); } } }