77 lines
1.7 KiB
C#
77 lines
1.7 KiB
C#
using Bimix.Application.DTOModels;
|
|
using Bimix.Application.DTOModels.Common;
|
|
using Bimix.Domain.Entities;
|
|
using Bimix.UI.Shared.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace Bimix.UI.Shared.Components;
|
|
|
|
public partial class ProductListComponent : ComponentBase
|
|
{
|
|
[Inject] private ProductService ProductService { get; set; } = default!;
|
|
|
|
private PagedResult<ProductDto> products = new();
|
|
private ProductFilterRequest filterRequest = new();
|
|
private bool isLoading = false;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadProducts();
|
|
}
|
|
|
|
private async Task StartBarcodeScanner()
|
|
{
|
|
|
|
}
|
|
|
|
private async Task LoadProducts()
|
|
{
|
|
isLoading = true;
|
|
|
|
try
|
|
{
|
|
products = await ProductService.GetProductsAsync(filterRequest);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Loading products failed: {ex.Message}");
|
|
}
|
|
finally
|
|
{
|
|
isLoading = false;
|
|
}
|
|
}
|
|
|
|
private async Task SearchProducts()
|
|
{
|
|
filterRequest.Page = 1;
|
|
await LoadProducts();
|
|
}
|
|
|
|
private async Task OnPageChanged(int page)
|
|
{
|
|
filterRequest.Page = page;
|
|
await LoadProducts();
|
|
}
|
|
|
|
private async Task ClearFilters()
|
|
{
|
|
filterRequest = new ProductFilterRequest();
|
|
await LoadProducts();
|
|
}
|
|
|
|
private async Task EditProduct(Guid productId)
|
|
{
|
|
// TODO
|
|
Console.WriteLine($"Edytuj produkt: {productId}");
|
|
}
|
|
|
|
private async Task DeleteProduct(Guid productId)
|
|
{
|
|
// TODO
|
|
Console.WriteLine($"Usuń produkt: {productId}");
|
|
}
|
|
|
|
} |