Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using RecRoomArchive.Models.API.Avatar;
|
|
using RecRoomArchive.Models.API.Setting;
|
|
using RecRoomArchive.Services;
|
|
using System.Text.Json;
|
|
|
|
namespace RecRoomArchive.Controllers.API.Settings.V2
|
|
{
|
|
[Route(template: "api/[controller]/v2")]
|
|
[ApiController]
|
|
public class SettingsController(FileService fileService) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<ActionResult<List<Setting>>> GetSettings()
|
|
{
|
|
var settingsData = fileService.GetData("settings.json");
|
|
|
|
if (string.IsNullOrWhiteSpace(settingsData))
|
|
{
|
|
return Ok(new List<Setting>());
|
|
}
|
|
|
|
var settings = JsonSerializer.Deserialize<List<Setting>>(settingsData);
|
|
return Ok(settings);
|
|
}
|
|
|
|
[HttpPost(template: "set")]
|
|
public async Task<ActionResult> SetSetting(Setting setting)
|
|
{
|
|
var settingsData = fileService.GetData("settings.json");
|
|
|
|
var settings = string.IsNullOrWhiteSpace(settingsData) ? [] : JsonSerializer.Deserialize<List<Setting>>(settingsData) ?? [];
|
|
|
|
settings.RemoveAll(x => x.Key == setting.Key);
|
|
settings.Add(setting);
|
|
|
|
fileService.SetData("settings.json", JsonSerializer.Serialize(settings));
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
} |