24 lines
861 B
C#
24 lines
861 B
C#
namespace Netina.Repository.Handlers.Faqs;
|
|
|
|
public class UpdateFaqCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper)
|
|
: IRequestHandler<UpdateFaqCommand, bool>
|
|
{
|
|
public async Task<bool> Handle(UpdateFaqCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var ent = await martenRepositoryWrapper.SetRepository<BaseFaq>()
|
|
.GetEntityAsync(request.Id, cancellationToken);
|
|
if (ent == null)
|
|
throw new BaseApiException(ApiResultStatusCode.NotFound, "Faq not found");
|
|
|
|
var newEnt = new BaseFaq
|
|
{
|
|
Id = ent.Id,
|
|
Faqs = request.Faqs,
|
|
Slug = request.Slug,
|
|
Title = request.Title
|
|
};
|
|
await martenRepositoryWrapper.SetRepository<BaseFaq>()
|
|
.UpdateEntityAsync(newEnt, cancellationToken);
|
|
return true;
|
|
}
|
|
} |