I hope that i can find an answer here.
I had tried both InputNumber from Microsoft .NET or even NumberInput from Blazor Bootstrap.
<NumberInput
TValue="int"
@bind-Value="@_quantity"
@onchange="@(e => _quantity = (int)e.Value)"
EnableMinMax="true"
Min="1"
Max="300"
Class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
Placeholder="1"
/>
@* <InputNumber *@
@* TValue="int" *@
@* @bind-Value="OrderItemRequestInput.Quantity" *@
@* name="Quantity" *@
@* id="Quantity" *@
@* class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" *@
@* placeholder="1" *@
@* required/> *@
private PagedResult<SpecificOrderResponse> _orders;
[Parameter]
public PagedResult<SpecificOrderResponse> Orders
{
get => _orders;
set
{
_orders = value;
if (_orders?.Results?.Any() == true)
{
OrderItemRequestInput.OrderId = _orders.Results.First().Id;
}
}
}
[SupplyParameterFromForm] private CreateOrderItemRequest OrderItemRequestInput { get; set; } = new();
private async Task AddOrderItem(EditContext editContext)
{
if (!editContext.Validate())
{
return;
}
Logger.LogInformation($"_Quantity Input: {_quantity}");
OrderItemRequestInput.Quantity = _quantity;
Logger.LogInformation($"Quantity Input: {OrderItemRequestInput.Quantity}");
OrderItemRequestInput.UnitId = SelectedUnitId.Value;
OrderItemRequestInput.ProductId = Product.ID;
OrderItemRequestInput.ResellerPrice = (decimal)CustomerPriceExGST;
Logger.LogInformation($"Order id {OrderItemRequestInput.OrderId} is selected");
Logger.LogInformation($"Add {OrderItemRequestInput.Quantity} product: {OrderItemRequestInput.ProductId} to order: {OrderItemRequestInput.OrderId}");
if (LnkOrderItemService == null)
{
Logger.LogError("LnkOrderItemService is null");
return;
}
if (HttpContextAccessor == null || HttpContextAccessor.HttpContext == null)
{
Logger.LogError("HttpContextAccessor or HttpContextAccessor.HttpContext is null");
return;
}
try
{
OrderItemResponse = await LnkOrderItemService.AddOrderItemIntoOrder(HttpContextAccessor.HttpContext, OrderItemRequestInput);
Console.WriteLine("Result Message: " + OrderItemResponse.Message);
}
catch (Exception ex)
{
Logger.LogError($"Add {OrderItemRequestInput.Quantity} product: {OrderItemRequestInput.ProductId} with unit: {OrderItemRequestInput.UnitId} to order: {OrderItemRequestInput.OrderId} has error {ex.StackTrace}");
}
}
On the UI, i have tried to put 2 or 3 or even 300. However, the OrderLineItemRequestInput.Quantity is always 1
Is there anything i do wrong?
I try to get input of Quantity from EditForm above.