You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.5 KiB
97 lines
2.5 KiB
using Blazored.LocalStorage;
|
|
using Blazored.Modal;
|
|
using Blazored.Modal.Services;
|
|
using Blazorise.DataGrid;
|
|
using ValblazeProject.Models;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Localization;
|
|
using ValblazeProject.Modals;
|
|
using ValblazeProject.Services;
|
|
using ValblazeProject.Components;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
|
namespace ValblazeProject.Pages
|
|
{
|
|
public partial class Inventaire
|
|
{
|
|
private List<Item> items;
|
|
private int totalItem;
|
|
|
|
[Inject]
|
|
public IStringLocalizer<List> Localizer { get; set; }
|
|
|
|
[Inject]
|
|
public IDataService DataService { get; set; }
|
|
|
|
[Inject]
|
|
public IWebHostEnvironment WebHostEnvironment { get; set; }
|
|
|
|
[Inject]
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
private List<CraftingRecipe> Recipes { get; set; } = new List<CraftingRecipe>();
|
|
|
|
[CascadingParameter]
|
|
public IModalService Modal { get; set; }
|
|
|
|
private string _searchText;
|
|
|
|
public string SearchText
|
|
{
|
|
get { return _searchText; }
|
|
set
|
|
{
|
|
_searchText = value;
|
|
OnSearch(_searchText);
|
|
}
|
|
}
|
|
|
|
public async Task OnSearch(string _searchText)
|
|
{
|
|
/* foreach(var item in items)
|
|
{
|
|
if(item.Name == rechercheText)
|
|
{
|
|
rechercheItems.Add(item);
|
|
}
|
|
}*/
|
|
TODO
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|