|
|
|
@ -1,6 +1,12 @@
|
|
|
|
|
using Blazored.LocalStorage;
|
|
|
|
|
using Blazored.Modal;
|
|
|
|
|
using Blazored.Modal.Services;
|
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using System;
|
|
|
|
|
using myBlazorApp.Modals;
|
|
|
|
|
using myBlazorApp.Models;
|
|
|
|
|
using myBlazorApp.Services;
|
|
|
|
|
|
|
|
|
|
namespace myBlazorApp.Pages
|
|
|
|
|
{
|
|
|
|
|
public partial class Inventory
|
|
|
|
@ -14,6 +20,52 @@ namespace myBlazorApp.Pages
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
|
|
|
|
|
[CascadingParameter]
|
|
|
|
|
public IModalService Modal { get; set; }
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int totalItem;
|
|
|
|
|
|
|
|
|
|
private List<Item> items;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
|
{
|
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void OnDelete(int id)
|
|
|
|
|
{
|
|
|
|
|
var parameters = new ModalParameters();
|
|
|
|
|
parameters.Add(nameof(Item.Id), id);
|
|
|
|
|
|
|
|
|
|
var modal = Modal.Show<DeleteConfirmation>("Delete Confirmation", parameters);
|
|
|
|
|
var result = await modal.Result;
|
|
|
|
|
|
|
|
|
|
if (result.Cancelled)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await DataService.Delete(id);
|
|
|
|
|
|
|
|
|
|
// Reload the page
|
|
|
|
|
NavigationManager.NavigateTo("list", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|