using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; namespace OI.Metrology.ClientHub.Pages; public partial class RunInfo { [Parameter] public int? HeaderId { get; set; } [Parameter] public int? ToolTypeId { get; set; } [Parameter] public Metrology.Shared.ViewModels.RunInfo? Model { get; set; } [Inject] protected IJSRuntime? JSRuntime { get; set; } [Inject] protected Models.AppSettings? AppSettings { get; set; } protected override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { if (JSRuntime is null) throw new NullReferenceException(nameof(JSRuntime)); if (AppSettings is null) throw new NullReferenceException(nameof(AppSettings)); int initialHeaderId = Model is not null ? Model.HeaderID : HeaderId is not null ? HeaderId.Value : 0; string initialHeaderAttachmentId = Model is not null ? Model.HeaderAttachmentID.ToString() : string.Empty; int initialToolTypeID = Model is not null ? Model.ToolTypeID : ToolTypeId is not null ? ToolTypeId.Value : 1; return JSRuntime.InvokeVoidAsync("initRunInfo", AppSettings.ApiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId).AsTask(); } return Task.CompletedTask; } }