Add broadcast scheduling features: implement Show and Channel entities, enhance AppDbContext and DependencyInjection for broadcasting, and update API routing. Include migration for new database schema and update documentation for broadcast-related functionalities.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Library.RemoveEpisode;
|
||||
|
||||
public sealed record RemoveEpisodeCommand(Guid ShowId, Guid EpisodeId) : ICommand<Result>;
|
||||
@@ -0,0 +1,26 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Library.RemoveEpisode;
|
||||
|
||||
public sealed class RemoveEpisodeCommandHandler(IAppDbContext dbContext)
|
||||
: ICommandHandler<RemoveEpisodeCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(
|
||||
RemoveEpisodeCommand command,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var show = await dbContext.Shows
|
||||
.Include(s => s.Episodes)
|
||||
.FirstOrDefaultAsync(s => s.Id == command.ShowId, cancellationToken);
|
||||
if (show is null)
|
||||
return Result.Failure(ShowErrors.NotFound);
|
||||
|
||||
return show.RemoveEpisode(command.EpisodeId)
|
||||
? Result.Success()
|
||||
: Result.Failure(ShowErrors.EpisodeNotFound);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user