23 lines
795 B
C#
23 lines
795 B
C#
using MediatR;
|
|
using Modules.Library.Application.Commands.Anime.Models;
|
|
using Modules.Library.Application.Gateways;
|
|
|
|
namespace Modules.Library.Application.Commands.Anime.Title;
|
|
|
|
public class AddEpisodeCommand : IRequest<Guid>
|
|
{
|
|
public Guid TitleId { get; set; }
|
|
public AnimeEpisodeType Type { get; set; }
|
|
|
|
}
|
|
|
|
public class AddEpisodeCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<AddEpisodeCommand, Guid>
|
|
{
|
|
public async Task<Guid> Handle(AddEpisodeCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var title = await titleGateway.GetById(request.TitleId);
|
|
var episode = title.AddEpisode((Domain.Entities.MediaContent.Items.Anime.AnimeEpisodeType)request.Type);
|
|
await titleGateway.Update(title);
|
|
return episode.Id;
|
|
}
|
|
} |