Add CreateTemplate endpoint and related functionality for channels without grids
Implement a new API endpoint to create a template for channels lacking a grid, enhancing the template management capabilities. Update frontend components to support the creation of templates directly from the channel detail view, including user feedback and translations for improved clarity. Add integration tests to ensure the new functionality works as expected.
This commit is contained in:
@@ -6,6 +6,7 @@ using TeleWave.Application.Programming.Planning.Preview;
|
||||
using TeleWave.Application.Programming.Templates;
|
||||
using TeleWave.Application.Programming.Templates.CopyTemplate;
|
||||
using TeleWave.Application.Programming.Templates.CreateSlot;
|
||||
using TeleWave.Application.Programming.Templates.CreateTemplate;
|
||||
using TeleWave.Application.Programming.Templates.DeleteSlot;
|
||||
using TeleWave.Application.Programming.Templates.GetTemplate;
|
||||
using TeleWave.Application.Programming.Templates.Layers;
|
||||
@@ -30,6 +31,10 @@ public static class TemplateEndpoints
|
||||
admin
|
||||
.MapGet("/channels/{channelId:guid}/template", GetTemplate)
|
||||
.Produces<ScheduleTemplateDto>();
|
||||
// Завести сетку каналу, у которого её нет (напр. пережившему снос старой ротации).
|
||||
admin
|
||||
.MapPost("/channels/{channelId:guid}/template", CreateTemplate)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
admin
|
||||
.MapPut("/templates/{templateId:guid}", UpdateTemplate)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
@@ -81,6 +86,24 @@ public static class TemplateEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> CreateTemplate(
|
||||
Guid channelId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new CreateChannelTemplateCommand(channelId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created(
|
||||
$"/api/admin/channels/{channelId}/template",
|
||||
new CreatedIdResponse(result.Value)
|
||||
)
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ApplyTemplate(
|
||||
Guid channelId,
|
||||
ISender sender,
|
||||
|
||||
Reference in New Issue
Block a user