@page "/events/edit" @using Microsoft.EntityFrameworkCore @using Core.Entities @using Data @inject AppDbContext context @inject NavigationManager NavigationManager Edit

Edit

EventDefinition


@if (EventDefinition is null) {

Loading...

} else {
@foreach (var format in Enum.GetValues(typeof(EventFormat))) { }
}
Back to List
@code { [SupplyParameterFromQuery] private int Id { get; set; } [SupplyParameterFromForm] private EventDefinition? EventDefinition { get; set; } protected override async Task OnInitializedAsync() { EventDefinition ??= await context.Events.FirstOrDefaultAsync(m => m.Id == Id); if (EventDefinition is null) { NavigationManager.NavigateTo("notfound"); } } // To protect from overposting attacks, enable the specific properties you want to bind to. // For more information, see https://learn.microsoft.com/aspnet/core/blazor/forms/#mitigate-overposting-attacks. private async Task UpdateEventDefinition() { context.Attach(EventDefinition!).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventDefinitionExists(EventDefinition!.Id)) { NavigationManager.NavigateTo("notfound"); } else { throw; } } NavigationManager.NavigateTo("/events"); } private bool EventDefinitionExists(int id) { return context.Events.Any(e => e.Id == id); } }