Files
ersatztv/ErsatzTV/Controllers/Api/Requests/UpdateXmltvSettingsRequest.cs
T
timothyandClaude Fable 5 540def7f17
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 4m51s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 5m21s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
fix: address #93 adversarial review findings
Backend: 401 documented on all mutating settings/resolution routes;
resolution delete distinguishes 404 (unknown) from 422 (not custom);
XMLTV enum bridging via exhaustive switch instead of int casts;
field-level Arg.Is assertions incl. non-null watermark/filler flow.

Frontend: resolution add/delete failures surfaced inline (were
silent); partial saves merge succeeded groups via allSettled; empty
numeric fields invalid + tunerCount min 1; HLS Direct select shows
out-of-list wire values; media-source rows show derived last-scan.

ErsatzTV.Tests 495; web suite 145.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 09:22:51 +02:00

34 lines
1.4 KiB
C#

using ErsatzTV.Application.Configuration;
using ApiXmltvBlockBehavior = ErsatzTV.Core.Api.Settings.XmltvBlockBehavior;
using ApiXmltvTimeZone = ErsatzTV.Core.Api.Settings.XmltvTimeZone;
namespace ErsatzTV.Controllers.Api.Requests;
public record UpdateXmltvSettingsRequest(int DaysToBuild, ApiXmltvTimeZone TimeZone, ApiXmltvBlockBehavior BlockBehavior)
{
public UpdateXmltvSettings ToCommand() =>
new(
new XmltvSettingsViewModel
{
DaysToBuild = DaysToBuild,
TimeZone = ToVmTimeZone(TimeZone),
BlockBehavior = ToVmBlockBehavior(BlockBehavior)
});
private static XmltvTimeZone ToVmTimeZone(ApiXmltvTimeZone timeZone) =>
timeZone switch
{
ApiXmltvTimeZone.Local => XmltvTimeZone.Local,
ApiXmltvTimeZone.Utc => XmltvTimeZone.Utc,
_ => throw new ArgumentOutOfRangeException(nameof(timeZone), timeZone, null)
};
private static XmltvBlockBehavior ToVmBlockBehavior(ApiXmltvBlockBehavior blockBehavior) =>
blockBehavior switch
{
ApiXmltvBlockBehavior.SplitTimeEvenly => XmltvBlockBehavior.SplitTimeEvenly,
ApiXmltvBlockBehavior.UseActualTimes => XmltvBlockBehavior.UseActualTimes,
_ => throw new ArgumentOutOfRangeException(nameof(blockBehavior), blockBehavior, null)
};
}