using MediatR;
using Modules.Rating.Api.Database.Entities;
using Modules.Rating.Api.Repositories;

namespace Modules.Rating.Api.Commands;

public class UnrateObjectCommand : IRequest<Unit>
{
    public Guid ObjectId { get; set; }
    public Guid SubjectId { get; set; }

}

public class UnrateObjectCommandHandler(RatingRepository repository) : IRequestHandler<UnrateObjectCommand, Unit>
{
    public async Task<Unit> Handle(UnrateObjectCommand request, CancellationToken cancellationToken)
    {
        //var key = new RateKey
        //{
        //    ObjectId = request.ObjectId,
        //    SubjectId = request.SubjectId,
        //};
        //if (await repository.IsRateExists(key)) await repository.DeleteAsync(key);
        //await repository.DeleteAsync(new RateKey
        //{
        //    ObjectId = request.ObjectId,
        //    SubjectId = request.SubjectId,
        //});
        await repository.DeleteAsync(request.ObjectId, request.SubjectId);
        return Unit.Value;
    }
}