using LiteCqrs;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Common.Models;
using TeleWave.Domain.Library;

namespace TeleWave.Application.Library.CreateShow;

public sealed class CreateShowCommandHandler(IAppDbContext dbContext)
    : ICommandHandler<CreateShowCommand, Result<Guid>>
{
    public Task<Result<Guid>> Handle(CreateShowCommand command, CancellationToken cancellationToken)
    {
        var show = Show.Create(
            command.Name,
            command.Kind,
            command.Description,
            command.OriginalName,
            command.Audience
        );
        dbContext.Shows.Add(show);
        return Task.FromResult(Result.Success(show.Id));
    }
}
