Crafting change
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user