initial commit

This commit is contained in:
2026-07-21 14:14:44 +07:00
commit fa7dbb970d
1359 changed files with 104110 additions and 0 deletions
@@ -0,0 +1,59 @@
using Indotalent.Infrastructure.Database;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Indotalent.Features.Thirdparty.Customer.Cqrs;
public class UpdateCustomerContactRequest
{
public string? Id { get; set; }
public string? Name { get; set; }
public string? JobTitle { get; set; }
public string? PhoneNumber { get; set; }
public string? EmailAddress { get; set; }
public string? Description { get; set; }
}
public class UpdateCustomerContactResponse
{
public string? Id { get; set; }
public bool Success { get; set; }
}
public record UpdateCustomerContactCommand(UpdateCustomerContactRequest Data) : IRequest<UpdateCustomerContactResponse>;
public class UpdateCustomerContactHandler : IRequestHandler<UpdateCustomerContactCommand, UpdateCustomerContactResponse>
{
private readonly AppDbContext _context;
public UpdateCustomerContactHandler(AppDbContext context) => _context = context;
public async Task<UpdateCustomerContactResponse> Handle(UpdateCustomerContactCommand request, CancellationToken cancellationToken)
{
var entity = await _context.CustomerContact
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
if (entity == null)
{
return new UpdateCustomerContactResponse
{
Id = request.Data.Id,
Success = false
};
}
entity.Name = request.Data.Name;
entity.JobTitle = request.Data.JobTitle;
entity.PhoneNumber = request.Data.PhoneNumber;
entity.EmailAddress = request.Data.EmailAddress;
entity.Description = request.Data.Description;
await _context.SaveChangesAsync(cancellationToken);
return new UpdateCustomerContactResponse
{
Id = entity.Id,
Success = true
};
}
}