using LiteCqrs;
using Microsoft.EntityFrameworkCore;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Common.Models;

namespace TeleWave.Application.Maintenance.DeleteAllShows;

public sealed class DeleteAllShowsCommandHandler(IAppDbContext dbContext)
    : ICommandHandler<DeleteAllShowsCommand, Result<int>>
{
    public async Task<Result<int>> Handle(
        DeleteAllShowsCommand command,
        CancellationToken cancellationToken
    )
    {
        // Серии удаляются каскадом (FK Show → ShowEpisode: OnDelete Cascade).
        var deleted = await dbContext.Shows.ExecuteDeleteAsync(cancellationToken);
        return Result.Success(deleted);
    }
}
