47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Moonlight.Api.Shared.Frontend;
|
|
using Moonlight.Shared;
|
|
using Moonlight.Shared.Admin.Sys.Settings;
|
|
|
|
namespace Moonlight.Api.Admin.Sys.Settings;
|
|
|
|
[ApiController]
|
|
[Authorize(Policy = Permissions.System.Settings)]
|
|
[Route("api/admin/system/settings/whiteLabeling")]
|
|
public class WhiteLabelingController : Controller
|
|
{
|
|
private readonly FrontendService FrontendService;
|
|
private readonly SettingsService SettingsService;
|
|
|
|
public WhiteLabelingController(SettingsService settingsService, FrontendService frontendService)
|
|
{
|
|
SettingsService = settingsService;
|
|
FrontendService = frontendService;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult<WhiteLabelingDto>> GetAsync()
|
|
{
|
|
var dto = new WhiteLabelingDto
|
|
{
|
|
Name = await SettingsService.GetValueAsync<string>(FrontendSettingConstants.Name) ?? "Moonlight"
|
|
};
|
|
|
|
return dto;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult<WhiteLabelingDto>> PostAsync([FromBody] SetWhiteLabelingDto request)
|
|
{
|
|
await SettingsService.SetValueAsync(FrontendSettingConstants.Name, request.Name);
|
|
await FrontendService.ResetCacheAsync();
|
|
|
|
var dto = new WhiteLabelingDto
|
|
{
|
|
Name = await SettingsService.GetValueAsync<string>(FrontendSettingConstants.Name) ?? "Moonlight"
|
|
};
|
|
|
|
return dto;
|
|
}
|
|
} |