MyBookmark/Modules.Library.Application/Commands/Anime/Title/Properties/RelatedContent/AddRelatedContentCommand.cs
THE_KONDRAT 7b16d72329 ui and login
mongo => postgres
2024-11-03 16:08:39 +03:00

24 lines
965 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 string ContentType { 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, request.ContentType);
await titleGateway.Update(title);
return Unit.Value;
}
}