oi-metrology/View/Pages/RunInfo.razor.cs
2023-02-04 10:17:21 -07:00

32 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace OI.Metrology.View;
public partial class RunInfo
{
[Parameter] public int? HeaderId { get; set; }
[Parameter] public int? ToolTypeId { 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));
Metrology.Shared.ViewModels.RunInfo? model = null;
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;
}
}