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

24 lines
923 B
C#

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