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,83 @@
using Application.Common.CQS.Queries;
using Application.Common.Extensions;
using AutoMapper;
using Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Application.Features.VendorContactManager.Queries;
public record GetVendorContactByVendorIdListDto
{
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? VendorId { get; set; }
public string? VendorName { get; set; }
public DateTime? CreatedAtUtc { get; init; }
}
public class GetVendorContactByVendorIdListProfile : Profile
{
public GetVendorContactByVendorIdListProfile()
{
CreateMap<VendorContact, GetVendorContactByVendorIdListDto>()
.ForMember(
dest => dest.VendorName,
opt => opt.MapFrom(src => src.Vendor != null ? src.Vendor.Name : string.Empty)
);
}
}
public class GetVendorContactByVendorIdListResult
{
public List<GetVendorContactByVendorIdListDto>? Data { get; init; }
}
public class GetVendorContactByVendorIdListRequest : IRequest<GetVendorContactByVendorIdListResult>
{
public string? VendorId { get; init; }
}
public class GetVendorContactByVendorIdListHandler : IRequestHandler<GetVendorContactByVendorIdListRequest, GetVendorContactByVendorIdListResult>
{
private readonly IMapper _mapper;
private readonly IQueryContext _context;
public GetVendorContactByVendorIdListHandler(IMapper mapper, IQueryContext context)
{
_mapper = mapper;
_context = context;
}
public async Task<GetVendorContactByVendorIdListResult> Handle(GetVendorContactByVendorIdListRequest request, CancellationToken cancellationToken)
{
var query = _context
.VendorContact
.AsNoTracking()
.IsDeletedEqualTo(false)
.Include(x => x.Vendor)
.Where(x => x.VendorId == request.VendorId)
.AsQueryable();
var entities = await query.ToListAsync(cancellationToken);
var dtos = _mapper.Map<List<GetVendorContactByVendorIdListDto>>(entities);
return new GetVendorContactByVendorIdListResult
{
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.VendorContactManager.Queries;
public record GetVendorContactListDto
{
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? VendorId { get; set; }
public string? VendorName { get; set; }
public DateTime? CreatedAtUtc { get; init; }
}
public class GetVendorContactListProfile : Profile
{
public GetVendorContactListProfile()
{
CreateMap<VendorContact, GetVendorContactListDto>()
.ForMember(
dest => dest.VendorName,
opt => opt.MapFrom(src => src.Vendor != null ? src.Vendor.Name : string.Empty)
);
}
}
public class GetVendorContactListResult
{
public List<GetVendorContactListDto>? Data { get; init; }
}
public class GetVendorContactListRequest : IRequest<GetVendorContactListResult>
{
public bool IsDeleted { get; init; } = false;
}
public class GetVendorContactListHandler : IRequestHandler<GetVendorContactListRequest, GetVendorContactListResult>
{
private readonly IMapper _mapper;
private readonly IQueryContext _context;
public GetVendorContactListHandler(IMapper mapper, IQueryContext context)
{
_mapper = mapper;
_context = context;
}
public async Task<GetVendorContactListResult> Handle(GetVendorContactListRequest request, CancellationToken cancellationToken)
{
var query = _context
.VendorContact
.AsNoTracking()
.IsDeletedEqualTo(request.IsDeleted)
.Include(x => x.Vendor)
.AsQueryable();
var entities = await query.ToListAsync(cancellationToken);
var dtos = _mapper.Map<List<GetVendorContactListDto>>(entities);
return new GetVendorContactListResult
{
Data = dtos
};
}
}