protected override async Task OnInitializedAsync() { if (ScheduleService != null && DateTimeService != null && !string.IsNullOrWhiteSpace(ShowId)) { if (IsCreatingNewShow) { var nxtThrsdy = DateTime.Today.AddDays(1).GetNextWeekday(DayOfWeek.Thursday); var offset = DateTimeService.GetCentralTimeZoneOffset(nxtThrsdy); Episode = Mapper?.Map <ShowModel>(new DocsShow { Date = new DateTimeOffset( nxtThrsdy.Year, nxtThrsdy.Month, nxtThrsdy.Day, 11, 0, 0, offset) }) !; } else { _show = await ScheduleService.GetShowAsync(ShowId); Episode = Mapper?.Map <ShowModel>(_show) !; } _editContext = new EditContext(Episode); _editContext.OnFieldChanged += OnModelChanged; } }
protected override void OnInitialized() { if (DateTimeService != null && ProtectionProvider != null && !string.IsNullOrWhiteSpace(ShowDate)) { var dateRoute = ShowDate.Decrypt(ProtectionProvider); int[]? parts = dateRoute.Split("-").Select(str => int.Parse(str)).ToArray(); (int month, int day, int year) = (parts[0], parts[1], parts[2]); RequestShow = new RequestModel { ShowDate = new DateTimeOffset( year, month, day, 11, 0, 0, DateTimeService.GetCentralTimeZoneOffset( new DateTime(year, month, day))) }; _editContext = new EditContext(RequestShow); _editContext.OnFieldChanged += OnModelChanged; } }