* Added maintaining Products
* Extended DataModels * Extended API
This commit is contained in:
76
OrdersManagement/Components/Pages/Products.razor
Normal file
76
OrdersManagement/Components/Pages/Products.razor
Normal file
@@ -0,0 +1,76 @@
|
||||
@page "/Products"
|
||||
|
||||
@using Syncfusion.Blazor.Grids
|
||||
@using Syncfusion.Blazor.Cards
|
||||
@using Action = Syncfusion.Blazor.Grids.Action
|
||||
@inject ProductService ProductService
|
||||
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||
|
||||
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||
<CardHeader>
|
||||
<h3 class="text-primary">Zarządzanie Indeksami</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<SfGrid DataSource="@_products"
|
||||
AllowPaging="true"
|
||||
ShowColumnMenu="true"
|
||||
Toolbar="@(new List<string> { "Update" })">
|
||||
<GridColumns>
|
||||
<GridColumn Field="@nameof(ProductDto.ID)" AllowEditing="false" IsPrimaryKey="true" HeaderText="ID" Width="70"></GridColumn>
|
||||
<GridColumn Field="@nameof(ProductDto.RecipientID)" AllowEditing="false" HeaderText="Odbiorca" Width="100"></GridColumn>
|
||||
<GridColumn Field="@nameof(ProductDto.RecipientIdx)" AllowEditing="false" HeaderText="Indeks odbiorcy" Width="100"></GridColumn>
|
||||
<GridColumn Field="@nameof(ProductDto.FaIdx)" HeaderText="Kod FA" Width="100"></GridColumn>
|
||||
</GridColumns>
|
||||
<GridEditSettings AllowEditing="true">
|
||||
</GridEditSettings>
|
||||
<GridEvents OnActionComplete="UserActionComplete"
|
||||
TValue="ProductDto">
|
||||
</GridEvents>
|
||||
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||
</SfGrid>
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||
</CardFooter>
|
||||
</SfCard>
|
||||
</div>
|
||||
@code {
|
||||
private IEnumerable<ProductDto>? _products { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||
//
|
||||
// if (currentUser.Identity?.IsAuthenticated == false)
|
||||
// {
|
||||
// NavigationManager.NavigateTo("/Unauthorized");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
await GetProducts();
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UserActionComplete(ActionEventArgs<ProductDto> args)
|
||||
{
|
||||
switch (args.RequestType)
|
||||
{
|
||||
case Action.Save:
|
||||
await ProductService.UpdateProductAsync(args.Data);
|
||||
await GetProducts();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GetProducts()
|
||||
{
|
||||
_products = await ProductService.GetProductsByIndexAsync("Uzupelnij") ?? new List<ProductDto>();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user