Add user full name and national code to order responses

This commit is contained in:
masoodafar-web
2025-11-27 18:21:17 +03:30
parent 32b7cb3238
commit c011645433
5 changed files with 80 additions and 6 deletions

View File

@@ -13,11 +13,38 @@ public class GetUserOrderQueryHandler : IRequestHandler<GetUserOrderQuery, GetUs
{
var response = await _context.UserOrders
.Include(i => i.UserAddress)
.Include(i => i.User)
.Include(i => i.FactorDetailss)
.ThenInclude(t=>t.Product)
.ThenInclude(t => t.Product)
.AsNoTracking()
.Where(x => x.Id == request.Id)
.ProjectToType<GetUserOrderResponseDto>()
.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,
FactorDetails = x.FactorDetailss.Select(fd => new GetUserOrderResponseFactorDetail
{
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),
UserNationalCode = x.User.NationalCode
})
.FirstOrDefaultAsync(cancellationToken);
return response ?? throw new NotFoundException(nameof(UserOrder), request.Id);

View File

@@ -31,6 +31,10 @@ public class GetUserOrderResponseDto
public string? TrackingCode { get; set; }
// توضیحات ارسال
public string? DeliveryDescription { get; set; }
// نام کامل کاربر
public string? UserFullName { get; set; }
// کدملی کاربر
public string? UserNationalCode { get; set; }
}public class GetUserOrderResponseFactorDetail
{