Stash and player management fix
This commit is contained in:
@@ -17,6 +17,7 @@ public class CharacterModel : AdminPageModel
|
||||
public DungeonCharacter Character { get; set; } = new();
|
||||
public List<DungeonCharacterItem> InventoryItems { get; set; } = new();
|
||||
public List<DungeonCharacterItem> EquippedItems { get; set; } = new();
|
||||
public List<DungeonStashItem> StashItems { get; set; } = new();
|
||||
|
||||
public string CdnBaseUrl { get; set; } = "https://assets.aeternalisgames.com";
|
||||
|
||||
@@ -54,6 +55,12 @@ public class CharacterModel : AdminPageModel
|
||||
|
||||
InventoryItems = allItems.Where(i => !i.IsEquipped).OrderBy(i => i.SlotIndex).ToList();
|
||||
EquippedItems = allItems.Where(i => i.IsEquipped).ToList();
|
||||
|
||||
StashItems = await _db.DungeonStashItems
|
||||
.Include(s => s.Definition)
|
||||
.Where(s => s.CharacterId == Character.Id)
|
||||
.OrderBy(s => s.SlotIndex)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostUpdateBasicAsync(
|
||||
@@ -158,4 +165,49 @@ public class CharacterModel : AdminPageModel
|
||||
|
||||
return RedirectToPage(new { id = characterId });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostUpdateStashItemAsync(
|
||||
ulong characterId,
|
||||
ulong stashItemId,
|
||||
int quantity,
|
||||
int slotIndex)
|
||||
{
|
||||
var item = await _db.DungeonStashItems
|
||||
.FirstOrDefaultAsync(s => s.Id == stashItemId && s.CharacterId == characterId);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
Message = "Stash item not found.";
|
||||
IsError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Quantity = Math.Max(1, quantity);
|
||||
item.SlotIndex = Math.Clamp(slotIndex, 0, 49);
|
||||
await _db.SaveChangesAsync();
|
||||
Message = "Stash item updated.";
|
||||
}
|
||||
|
||||
return RedirectToPage(new { id = characterId });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostDeleteStashItemAsync(ulong characterId, ulong stashItemId)
|
||||
{
|
||||
var item = await _db.DungeonStashItems
|
||||
.FirstOrDefaultAsync(s => s.Id == stashItemId && s.CharacterId == characterId);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
_db.DungeonStashItems.Remove(item);
|
||||
await _db.SaveChangesAsync();
|
||||
Message = "Stash item deleted.";
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "Stash item not found.";
|
||||
IsError = true;
|
||||
}
|
||||
|
||||
return RedirectToPage(new { id = characterId });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user