Resistance System
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using Server.Services.Auth;
|
||||
|
||||
namespace Server.Api;
|
||||
@@ -342,3 +343,37 @@ public class BootstrapRequest
|
||||
public string Username { get; set; } = "";
|
||||
public string BootstrapKey { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all resistance types for dropdowns
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/admin/resistances")]
|
||||
public class ResistanceTypesController : ControllerBase
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
|
||||
public ResistanceTypesController(GameDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var types = await _db.DamageResistanceTypes
|
||||
.Where(t => t.IsEnabled)
|
||||
.OrderBy(t => t.SortOrder)
|
||||
.Select(t => new { t.Key, t.DisplayName, t.Color })
|
||||
.ToListAsync();
|
||||
return Ok(types);
|
||||
}
|
||||
|
||||
[HttpGet("check/{key}")]
|
||||
public async Task<IActionResult> CheckExists(string key)
|
||||
{
|
||||
var exists = await _db.DamageResistanceTypes
|
||||
.AnyAsync(t => t.Key.ToLower() == key.ToLower() && t.IsEnabled);
|
||||
return Ok(new { exists });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user