44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using DataServer.Data;
|
|
using DataServer.Data.Entities;
|
|
|
|
namespace Server.Services.Admin.Pages.TileMaps;
|
|
|
|
public class IndexModel : AdminPageModel
|
|
{
|
|
private readonly GameDbContext _db;
|
|
private readonly IConfiguration _config;
|
|
|
|
public IndexModel(GameDbContext db, IConfiguration config)
|
|
{
|
|
_db = db;
|
|
_config = config;
|
|
}
|
|
|
|
public List<TileMapSheet> Sheets { get; set; } = new();
|
|
public string CdnBaseUrl { get; set; } = "";
|
|
|
|
public async Task OnGetAsync()
|
|
{
|
|
CdnBaseUrl = _config["Cdn:BaseUrl"] ?? "https://assets.aeternalisgames.com";
|
|
Sheets = await _db.TileMapSheets
|
|
.Include(s => s.Tiles)
|
|
.OrderBy(s => s.Name)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<IActionResult> OnPostDeleteAsync(int id)
|
|
{
|
|
var sheet = await _db.TileMapSheets.FindAsync(id);
|
|
if (sheet != null)
|
|
{
|
|
// Check if used in any room templates
|
|
// For now just delete - add check later
|
|
_db.TileMapSheets.Remove(sheet);
|
|
await _db.SaveChangesAsync();
|
|
}
|
|
return RedirectToPage();
|
|
}
|
|
}
|