feat(order): refactor order data mapping for improved clarity and structure
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 13m4s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 13m4s
- Updated GetAllDiscountOrdersQueryHandler to enhance order data mapping by using a more structured approach with AdminOrderDto. - Refactored user full name construction in GetCustomerOrderQueryHandler and GetCustomerOrdersQueryHandler to utilize UserDisplayName for better readability. - Added necessary using directives for consistency across query handlers.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
namespace CMSMicroservice.Application.Common;
|
||||
|
||||
/// <summary>
|
||||
/// نام نمایشی کاربر برای گزارشها؛ اگر نام خالی باشد موبایل یا شناسه.
|
||||
/// </summary>
|
||||
public static class UserDisplayName
|
||||
{
|
||||
public static string From(string? firstName, string? lastName, string? mobile, long userId)
|
||||
{
|
||||
var name = string.Join(" ",
|
||||
new[] { firstName, lastName }.Where(s => !string.IsNullOrWhiteSpace(s)));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
return name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mobile))
|
||||
return mobile.Trim();
|
||||
|
||||
return userId > 0 ? $"کاربر {userId}" : "—";
|
||||
}
|
||||
|
||||
public static string From(Domain.Entities.User? user)
|
||||
{
|
||||
if (user is null)
|
||||
return string.Empty;
|
||||
|
||||
return From(user.FirstName, user.LastName, user.Mobile, user.Id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user