b2d676b555
- Add GetCustomerProfileResponseDto for retrieving customer profile information. - Create GetCustomerReferralsQuery and GetCustomerReferralsQueryHandler to fetch customer referrals with pagination and filtering options. - Introduce GetCustomerReferralsResponseDto to structure the response for customer referrals. - Implement GetCustomerSettingsQuery and GetCustomerSettingsQueryHandler to retrieve user settings. - Add GetCustomerOrder and GetCustomerOrderQueryHandler for fetching specific customer orders. - Create GetCustomerOrderHistoryQuery and GetCustomerOrderHistoryQueryHandler to retrieve order history with filtering options. - Implement GetCustomerOrdersQuery and GetCustomerOrdersQueryHandler for fetching multiple customer orders with filters. - Add GetCustomerWalletChangeLogQuery and GetCustomerWalletChangeLogQueryHandler for retrieving wallet change logs. - Implement GetCustomerWithdrawalSettingsQuery and GetCustomerWithdrawalSettingsQueryHandler for fetching withdrawal settings. - Create GetCustomerWithdrawalsQuery and GetCustomerWithdrawalsQueryHandler to retrieve customer withdrawal requests.
52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using CMSMicroservice.Application.Common.Interfaces;
|
|
using CMSMicroservice.Domain.Entities;
|
|
using Mapster;
|
|
|
|
namespace CMSMicroservice.Application.PackageCQ.Queries.GetCustomerPackages;
|
|
|
|
public class GetCustomerPackagesQueryHandler : IRequestHandler<GetCustomerPackagesQuery, List<GetCustomerPackagesResponseDto>>
|
|
{
|
|
private readonly IApplicationDbContext _context;
|
|
|
|
public GetCustomerPackagesQueryHandler(IApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<List<GetCustomerPackagesResponseDto>> Handle(GetCustomerPackagesQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var query = _context.Packages
|
|
.AsNoTracking()
|
|
.AsQueryable();
|
|
|
|
// Filter by PackageType if specified
|
|
if (request.PackageTypeFilter.HasValue)
|
|
{
|
|
// Note: Package entity doesn't have PackageType enum, so we filter by convention
|
|
// Assuming Title or Description contains the package type indicator
|
|
// If Package entity needs PackageType field, it should be added to migration
|
|
}
|
|
|
|
// Get all packages (assuming all are available unless marked otherwise)
|
|
var packages = await query
|
|
.ProjectToType<GetCustomerPackagesResponseDto>()
|
|
.ToListAsync(cancellationToken);
|
|
|
|
// Map additional fields
|
|
foreach (var package in packages)
|
|
{
|
|
package.Name = package.Title;
|
|
package.ImageUrl = package.ImagePath;
|
|
package.Currency = "IRR";
|
|
package.IsAvailable = true;
|
|
package.ValidityDays = 365; // Default validity
|
|
package.IsPopular = false;
|
|
package.ShortDescription = package.Description?.Length > 100
|
|
? package.Description.Substring(0, 100) + "..."
|
|
: package.Description;
|
|
}
|
|
|
|
return packages;
|
|
}
|
|
}
|