Refactor ChannelEndpoints and ScheduleGenerator: consolidate endpoint logic into partial files, remove unused methods, and enhance dependency injection for scheduling. Update ChannelDetail component to streamline imports and improve UI structure.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Broadcast.CreateOverride;
|
||||
using TeleWave.Application.Broadcast.DeleteOverride;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
/// <summary>Эндпоинты временных override'ов / марафонов канала (разовые и еженедельные).</summary>
|
||||
public static partial class ChannelEndpoints
|
||||
{
|
||||
private static async Task<IResult> CreateOverride(
|
||||
Guid id,
|
||||
CreateOverrideBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new CreateProgrammingOverrideCommand(
|
||||
id,
|
||||
body.Mode,
|
||||
body.Recurrence,
|
||||
body.StartsAtUtc,
|
||||
body.EndsAtUtc,
|
||||
body.DayOfWeek,
|
||||
body.StartMinute,
|
||||
body.EndMinute,
|
||||
body.Shows
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> DeleteOverride(
|
||||
Guid id,
|
||||
Guid overrideId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new DeleteProgrammingOverrideCommand(id, overrideId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record CreateOverrideBody(
|
||||
OverrideMode Mode,
|
||||
OverrideRecurrence Recurrence,
|
||||
DateTimeOffset? StartsAtUtc,
|
||||
DateTimeOffset? EndsAtUtc,
|
||||
int? DayOfWeek,
|
||||
int? StartMinute,
|
||||
int? EndMinute,
|
||||
IReadOnlyList<OverrideShowInput> Shows
|
||||
);
|
||||
Reference in New Issue
Block a user