@page "/session/edit/{SessionId:guid}" @using GmRelay.Web.Services @using GmRelay.Shared.Domain @using Microsoft.AspNetCore.Authorization @attribute [Authorize] @inject SessionService SessionService @inject NavigationManager Navigation Edit Session - GM-Relay

Edit Session

@if (session == null) {

Loading session details...

} else {
Changing this will update all sessions in the same batch.
Current: @session.ScheduledAt.FormatMoscow()
@if (!string.IsNullOrEmpty(errorMessage)) {
@errorMessage
} }
@code { [Parameter] public Guid SessionId { get; set; } private WebSession? session; private SessionEditModel model = new(); private bool isSubmitting = false; private string? errorMessage; protected override async Task OnInitializedAsync() { session = await SessionService.GetSessionAsync(SessionId); if (session != null) { model.Title = session.Title; // Convert UTC to Moscow for the picker model.ScheduledAtLocal = session.ScheduledAt.ToMoscow(); model.JoinLink = session.JoinLink; } } private async Task HandleSubmit() { isSubmitting = true; errorMessage = null; try { // The value from is considered as "unspecified" or local to browser. // We treat it as Moscow time (UTC+3) and convert to UTC. var utcTime = new DateTimeOffset(model.ScheduledAtLocal, TimeSpan.FromHours(3)).ToUniversalTime().UtcDateTime; await SessionService.UpdateSessionAsync(SessionId, model.Title, utcTime, model.JoinLink); Navigation.NavigateTo($"/group/{session!.GroupId}"); } catch (Exception ex) { errorMessage = "Failed to save changes: " + ex.Message; } finally { isSubmitting = false; } } private void GoBack() => Navigation.NavigateTo("/"); public class SessionEditModel { public string Title { get; set; } = ""; public DateTime ScheduledAtLocal { get; set; } = DateTime.Now; public string JoinLink { get; set; } = ""; } }