@page "/CustomDescriptions/Delete/{CustomDescriptionId}"

@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;

@inject CustomDescriptionService customDescriptionService
@inject NavigationManager navigationManager

<h2>Delete Employee</h2>
<hr />
<h3>Are you sure want to delete this?</h3>
<form>
    <div class="row">
        <div class=" col-md-8">
            <div class="form-group">
                <label>CustomDescriptionId:</label>
                <label>@customDescription!.CustomDescriptionId</label>
            </div>
            <div class="form-group">
                <label>ProductNumber:</label>
                <label>@customDescription.ProductNumber</label>
            </div>
            <div class="form-group">
                <label>OptionNumber:</label>
                <label>@customDescription.OptionNumber</label>
            </div>
            <div class="form-group">
                <label>Heading:</label>
                <label>@customDescription.Heading</label>
            </div>
            <div class="form-group">
                <label>DescriptionText:</label>
                <label>@customDescription.DescriptionText</label>
            </div>
        </div>

    </div>
    <div class="row">
        <div class="col-md-4">
            <div class="form-group">
                <input type="button" class="btn btn-danger" @onclick="@DeleteCustomDescription" value="Delete" />
                <input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
            </div>
        </div>
    </div>
</form>

@code {
    [Parameter]
    public string customDescriptionId { get; set; } = string.Empty;
    CustomDescription customDescription = new CustomDescription();

    protected override async Task OnInitializedAsync()
    {
        customDescription = await Task.Run(() => customDescriptionService.GetCustomDescriptionAsync(Convert.ToUInt32(customDescriptionId)));
    }
    protected async void DeleteCustomDescription()
    {
        await customDescriptionService.DeleteCustomDescriptionAsync(customDescription);
        navigationManager.NavigateTo("CustomDescriptions/Index");
    }
    void Cancel()
    {
        navigationManager.NavigateTo("CustomDescriptions/Index");
    }
}