MyBookmark/Modules.Library.Application/Commands/Anime/Title/Properties/RelatedContent/AddRelatedContentCommand.cs
2024-09-23 03:00:50 +03:00

23 lines
888 B
C#

using MediatR;
using Modules.Library.Application.Commands.CommonModels;
using Modules.Library.Application.Gateways;
namespace Modules.Library.Application.Commands.Anime.Title.Properties.RelatedContent;
public class AddRelatedContentCommand : IRequest<Unit>
{
public Guid TitleId { get; set; }
public MediaInfoType Type { get; set; }
public string Url { get; set; } = default!;
}
public class AddRelatedContentCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<AddRelatedContentCommand, Unit>
{
public async Task<Unit> Handle(AddRelatedContentCommand request, CancellationToken cancellationToken)
{
var title = await titleGateway.GetById(request.TitleId);
title.CommonProperties.AddRelatedContent(request.Url, (Domain.Entities.MediaInfoType)request.Type);
await titleGateway.Update(title);
return Unit.Value;
}
}