2025-09-27 08:46:36 +03:30
|
|
|
namespace CMSMicroservice.Application.UserOrderCQ.Queries.GetUserOrder;
|
|
|
|
|
public class GetUserOrderQueryHandler : IRequestHandler<GetUserOrderQuery, GetUserOrderResponseDto>
|
|
|
|
|
{
|
|
|
|
|
private readonly IApplicationDbContext _context;
|
|
|
|
|
|
|
|
|
|
public GetUserOrderQueryHandler(IApplicationDbContext context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<GetUserOrderResponseDto> Handle(GetUserOrderQuery request,
|
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var response = await _context.UserOrders
|
2025-11-25 04:59:50 +03:30
|
|
|
.Include(i => i.UserAddress)
|
2025-11-27 18:21:17 +03:30
|
|
|
.Include(i => i.User)
|
Add validators and services for Product Galleries and Product Tags
- Implemented Create, Delete, Get, and Update validators for Product Galleries.
- Added Create, Delete, Get, and Update validators for Product Tags.
- Created service classes for handling Discount Categories, Discount Orders, Discount Products, Discount Shopping Cart, Product Categories, Product Galleries, and Product Tags.
- Each service class integrates with CQRS for command and query handling.
- Established mapping profiles for Product Galleries.
2025-12-04 02:40:49 +03:30
|
|
|
.Include(i => i.FactorDetails)
|
2025-11-27 18:21:17 +03:30
|
|
|
.ThenInclude(t => t.Product)
|
2025-12-05 17:26:58 +03:30
|
|
|
.Include(i => i.OrderVAT)
|
2025-09-27 08:46:36 +03:30
|
|
|
.AsNoTracking()
|
|
|
|
|
.Where(x => x.Id == request.Id)
|
2025-11-27 18:21:17 +03:30
|
|
|
.Select(x => new GetUserOrderResponseDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
Amount = x.Amount,
|
|
|
|
|
PackageId = x.PackageId ?? 0,
|
|
|
|
|
TransactionId = x.TransactionId,
|
|
|
|
|
PaymentStatus = x.PaymentStatus,
|
|
|
|
|
PaymentDate = x.PaymentDate,
|
|
|
|
|
UserId = x.UserId,
|
|
|
|
|
UserAddressId = x.UserAddressId,
|
|
|
|
|
PaymentMethod = x.PaymentMethod,
|
|
|
|
|
UserAddressText = x.UserAddress.Address,
|
Add validators and services for Product Galleries and Product Tags
- Implemented Create, Delete, Get, and Update validators for Product Galleries.
- Added Create, Delete, Get, and Update validators for Product Tags.
- Created service classes for handling Discount Categories, Discount Orders, Discount Products, Discount Shopping Cart, Product Categories, Product Galleries, and Product Tags.
- Each service class integrates with CQRS for command and query handling.
- Established mapping profiles for Product Galleries.
2025-12-04 02:40:49 +03:30
|
|
|
FactorDetails = x.FactorDetails.Select(fd => new GetUserOrderResponseFactorDetail
|
2025-11-27 18:21:17 +03:30
|
|
|
{
|
|
|
|
|
ProductId = fd.ProductId,
|
|
|
|
|
ProductTitle = fd.Product.Title,
|
|
|
|
|
ProductThumbnailPath = fd.Product.ThumbnailPath,
|
|
|
|
|
UnitPrice = fd.UnitPrice,
|
|
|
|
|
Count = fd.Count,
|
|
|
|
|
UnitDiscountPrice = fd.UnitDiscountPrice
|
|
|
|
|
}).ToList(),
|
|
|
|
|
DeliveryStatus = x.DeliveryStatus,
|
|
|
|
|
TrackingCode = x.TrackingCode,
|
|
|
|
|
DeliveryDescription = x.DeliveryDescription,
|
|
|
|
|
UserFullName = (x.User.FirstName ?? string.Empty) + " " + (x.User.LastName ?? string.Empty),
|
2025-12-05 17:26:58 +03:30
|
|
|
UserNationalCode = x.User.NationalCode,
|
|
|
|
|
VatInfo = x.OrderVAT != null ? new OrderVATInfoDto
|
|
|
|
|
{
|
|
|
|
|
VatRate = x.OrderVAT.VATRate,
|
|
|
|
|
BaseAmount = x.OrderVAT.BaseAmount,
|
|
|
|
|
VatAmount = x.OrderVAT.VATAmount,
|
|
|
|
|
TotalAmount = x.OrderVAT.TotalAmount,
|
|
|
|
|
IsPaid = x.OrderVAT.IsPaid
|
|
|
|
|
} : null
|
2025-11-27 18:21:17 +03:30
|
|
|
})
|
2025-09-27 08:46:36 +03:30
|
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
|
|
|
|
|
|
return response ?? throw new NotFoundException(nameof(UserOrder), request.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|