initial commit

This commit is contained in:
2026-07-21 15:03:40 +07:00
commit 5c20bb8a9e
2752 changed files with 864209 additions and 0 deletions
@@ -0,0 +1,83 @@
using Application.Common.CQS.Queries;
using Application.Common.Extensions;
using AutoMapper;
using Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Application.Features.CustomerContactManager.Queries;
public record GetCustomerContactByCustomerIdListDto
{
public string? Id { get; init; }
public string? Name { get; set; }
public string? Number { get; set; }
public string? JobTitle { get; set; }
public string? PhoneNumber { get; set; }
public string? EmailAddress { get; set; }
public string? Description { get; set; }
public string? CustomerId { get; set; }
public string? CustomerName { get; set; }
public DateTime? CreatedAtUtc { get; init; }
}
public class GetCustomerContactByCustomerIdListProfile : Profile
{
public GetCustomerContactByCustomerIdListProfile()
{
CreateMap<CustomerContact, GetCustomerContactByCustomerIdListDto>()
.ForMember(
dest => dest.CustomerName,
opt => opt.MapFrom(src => src.Customer != null ? src.Customer.Name : string.Empty)
);
}
}
public class GetCustomerContactByCustomerIdListResult
{
public List<GetCustomerContactByCustomerIdListDto>? Data { get; init; }
}
public class GetCustomerContactByCustomerIdListRequest : IRequest<GetCustomerContactByCustomerIdListResult>
{
public string? CustomerId { get; init; }
}
public class GetCustomerContactByCustomerIdListHandler : IRequestHandler<GetCustomerContactByCustomerIdListRequest, GetCustomerContactByCustomerIdListResult>
{
private readonly IMapper _mapper;
private readonly IQueryContext _context;
public GetCustomerContactByCustomerIdListHandler(IMapper mapper, IQueryContext context)
{
_mapper = mapper;
_context = context;
}
public async Task<GetCustomerContactByCustomerIdListResult> Handle(GetCustomerContactByCustomerIdListRequest request, CancellationToken cancellationToken)
{
var query = _context
.CustomerContact
.AsNoTracking()
.ApplyIsDeletedFilter(false)
.Include(x => x.Customer)
.Where(x => x.CustomerId == request.CustomerId)
.AsQueryable();
var entities = await query.ToListAsync(cancellationToken);
var dtos = _mapper.Map<List<GetCustomerContactByCustomerIdListDto>>(entities);
return new GetCustomerContactByCustomerIdListResult
{
Data = dtos
};
}
}
@@ -0,0 +1,82 @@
using Application.Common.CQS.Queries;
using Application.Common.Extensions;
using AutoMapper;
using Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Application.Features.CustomerContactManager.Queries;
public record GetCustomerContactListDto
{
public string? Id { get; init; }
public string? Name { get; set; }
public string? Number { get; set; }
public string? JobTitle { get; set; }
public string? PhoneNumber { get; set; }
public string? EmailAddress { get; set; }
public string? Description { get; set; }
public string? CustomerId { get; set; }
public string? CustomerName { get; set; }
public DateTime? CreatedAtUtc { get; init; }
}
public class GetCustomerContactListProfile : Profile
{
public GetCustomerContactListProfile()
{
CreateMap<CustomerContact, GetCustomerContactListDto>()
.ForMember(
dest => dest.CustomerName,
opt => opt.MapFrom(src => src.Customer != null ? src.Customer.Name : string.Empty)
);
}
}
public class GetCustomerContactListResult
{
public List<GetCustomerContactListDto>? Data { get; init; }
}
public class GetCustomerContactListRequest : IRequest<GetCustomerContactListResult>
{
public bool IsDeleted { get; init; } = false;
}
public class GetCustomerContactListHandler : IRequestHandler<GetCustomerContactListRequest, GetCustomerContactListResult>
{
private readonly IMapper _mapper;
private readonly IQueryContext _context;
public GetCustomerContactListHandler(IMapper mapper, IQueryContext context)
{
_mapper = mapper;
_context = context;
}
public async Task<GetCustomerContactListResult> Handle(GetCustomerContactListRequest request, CancellationToken cancellationToken)
{
var query = _context
.CustomerContact
.AsNoTracking()
.ApplyIsDeletedFilter(request.IsDeleted)
.Include(x => x.Customer)
.AsQueryable();
var entities = await query.ToListAsync(cancellationToken);
var dtos = _mapper.Map<List<GetCustomerContactListDto>>(entities);
return new GetCustomerContactListResult
{
Data = dtos
};
}
}