initial commit

This commit is contained in:
2026-07-21 15:36:49 +07:00
commit 77f66132bc
2640 changed files with 850901 additions and 0 deletions
@@ -0,0 +1,60 @@
using Application.Common.Repositories;
using Domain.Entities;
using FluentValidation;
using MediatR;
namespace Application.Features.LeadContactManager.Commands;
public class DeleteLeadContactResult
{
public LeadContact? Data { get; set; }
}
public class DeleteLeadContactRequest : IRequest<DeleteLeadContactResult>
{
public string? Id { get; init; }
public string? DeletedById { get; init; }
}
public class DeleteLeadContactValidator : AbstractValidator<DeleteLeadContactRequest>
{
public DeleteLeadContactValidator()
{
RuleFor(x => x.Id).NotEmpty();
}
}
public class DeleteLeadContactHandler : IRequestHandler<DeleteLeadContactRequest, DeleteLeadContactResult>
{
private readonly ICommandRepository<LeadContact> _repository;
private readonly IUnitOfWork _unitOfWork;
public DeleteLeadContactHandler(
ICommandRepository<LeadContact> repository,
IUnitOfWork unitOfWork
)
{
_repository = repository;
_unitOfWork = unitOfWork;
}
public async Task<DeleteLeadContactResult> Handle(DeleteLeadContactRequest request, CancellationToken cancellationToken)
{
var entity = await _repository.GetAsync(request.Id ?? string.Empty, cancellationToken);
if (entity == null)
{
throw new Exception($"Entity not found: {request.Id}");
}
entity.UpdatedById = request.DeletedById;
_repository.Delete(entity);
await _unitOfWork.SaveAsync(cancellationToken);
return new DeleteLeadContactResult
{
Data = entity
};
}
}