using Application.Abstractions.Data;
using Application.Abstractions.Messaging;
using Domain.Entities.News;

namespace Application.Features.Admin.Crypto.News.Source.Create
{
    public sealed class Handler(IAppDbContext db) : ICommandHandler<Command>
    {
        public async Task Handle(Command request, CancellationToken ct)
        {
            var source = RssFeedSource.Create(request.Name, request.Url, request.Description, request.IntervalMinutes);

            db.RssFeedSource.Add(source);
            await db.SaveChangesAsync(ct);
        }
    }
}