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.
46 lines
997 B
46 lines
997 B
using CraftSharp.Components;
|
|
using CraftSharp.Models;
|
|
using CraftSharp.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace CraftSharp.Components
|
|
{
|
|
public partial class DeleteItem
|
|
{
|
|
[Parameter]
|
|
public int Index { get; set; }
|
|
|
|
[Parameter]
|
|
public Item Item { get; set; }
|
|
|
|
[Parameter]
|
|
public bool NoDrop { get; set; }
|
|
|
|
[CascadingParameter]
|
|
public Crafting Parent { get; set; }
|
|
|
|
[Inject]
|
|
public CustomStateProvider AuthStateProvider { get; set; }
|
|
|
|
internal void OnDrop()
|
|
{
|
|
if (NoDrop)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.Item = Parent.CurrentDragItem;
|
|
|
|
if (AuthStateProvider.GetCurrentUser().Inventory.Any(n => n.Id == this.Item.Id))
|
|
{
|
|
AuthStateProvider.GetCurrentUser().DeleteItem(this.Item);
|
|
this.Item = null;
|
|
Parent.Suppression();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|