MyBookmark/Modules.Rating.Api/Commands/UnrateObjectCommand.cs
THE_KONDRAT 7b16d72329 ui and login
mongo => postgres
2024-11-03 16:08:39 +03:00

32 lines
1002 B
C#

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(RateRepository 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;
}
}