@page "/CustomDescriptions/Add"

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

@inject CustomDescriptionService customDescriptionService
@inject NavigationManager navigationManager

<h2>Add CustomDescription</h2>
<hr />

<form>
    <div class="row">
        <div class="col-md-8">
            <div class="form-group">
                <label for="CustomDescriptionId" class="control-label">CustomDescriptionId</label>
                <input form="CustomDescriptionId" class="form-control" @bind="@customDescription.CustomDescriptionId" />
            </div>
            <div class="form-group">
                <label for="ProductNumber" class="control-label">ProductNumber</label>
                <input form="ProductNumber" class="form-control" @bind="@customDescription.ProductNumber" />
            </div>
            <div class="form-group">
                <label for="OptionNumber" class="control-label">OptionNumber</label>
                <input form="OptionNumber" class="form-control" @bind="@customDescription.OptionNumber" />
            </div>
            <div class="form-group">
                <label for="Heading" class="control-label">Heading</label>
                <input form="Heading" class="form-control" @bind="@customDescription.Heading" />
            </div>
            <div class="form-group">
                <label for="DescriptionText" class="control-label">DescriptionText</label>
                <input form="DescriptionText" class="form-control" @bind="@customDescription.DescriptionText" />
            </div>
        </div>
    </div>

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

@code {
    CustomDescription customDescription = new CustomDescription();

    protected async void CreateCustomDescription()
    {
        customDescription.DataModificationByUser = "Gremlin_BlazorServer";

        if (await customDescriptionService.InsertCustomDescriptionAsync(customDescription))
        {
            navigationManager.NavigateTo("CustomDescriptions/Index");
        }
    }

    void Cancel() => navigationManager.NavigateTo("CustomDescriptions/Index");
}