Crafting change

This commit is contained in:
dingo
2025-12-28 09:36:40 -05:00
parent f1b2749526
commit 8cc54cfafd
9 changed files with 3029 additions and 18 deletions
+50
View File
@@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Server.Game.Dungeon;
namespace Server.Services.Admin.Pages;
public class ApiModel : AdminPageModel
{
private readonly CraftingHandler _craftingHandler;
public ApiModel(CraftingHandler craftingHandler)
{
_craftingHandler = craftingHandler;
}
public IActionResult OnGet()
{
return new JsonResult(new { error = "Method not allowed" }) { StatusCode = 405 };
}
public async Task<IActionResult> OnPostRefreshCacheAsync([FromQuery] string? type)
{
var refreshed = new List<string>();
try
{
if (type == null || type.Equals("recipes", StringComparison.OrdinalIgnoreCase))
{
await _craftingHandler.RefreshRecipeCacheAsync();
refreshed.Add("recipes");
}
return new JsonResult(new
{
success = true,
message = "Cache refreshed",
refreshed,
timestamp = DateTime.UtcNow
});
}
catch (Exception ex)
{
return new JsonResult(new
{
success = false,
error = ex.Message
}) { StatusCode = 500 };
}
}
}