Skip to content

Commit 9482e01

Browse files
DangDang
authored andcommitted
fix: ServiceOrder status API returns number and improve customer name fallback
- Change ServiceOrderDto.Status from string to int to return numeric status values - Update GetServiceOrdersQueryHandler to cast status enum to int - Improve dashboard recent-orders customerName fallback: Name -> Email -> Customer ID - Improve dealer name fallback: Name -> Email -> No Dealer Assigned - ServiceOrder status now returns: 1=Scheduled, 2=InProgress, 3=Completed, 4=Cancelled
1 parent 26991d7 commit 9482e01

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

VehicleShowroomManagement/src/Application/Features/Dashboard/Queries/GetRecentOrders/GetRecentOrdersQueryHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public async Task<List<RecentOrderDto>> Handle(GetRecentOrdersQuery request, Can
3838
{
3939
OrderId = order.Id,
4040
OrderNumber = order.Id, // Using ID as order number
41-
CustomerName = customer?.Name ?? customer?.Username ?? $"Customer ID: {order.CustomerId}",
41+
CustomerName = customer?.Name ?? customer?.Email ?? $"Customer ID: {order.CustomerId}",
4242
VehicleModel = model?.Name ?? order.ModelNumber,
4343
TotalAmount = order.SalePrice,
4444
Status = order.Status.ToString(),
4545
OrderDate = order.OrderDate,
46-
SalesPersonName = dealer?.Name ?? dealer?.Username ?? "No Dealer Assigned"
46+
SalesPersonName = dealer?.Name ?? dealer?.Email ?? "No Dealer Assigned"
4747
});
4848
}
4949
catch (Exception)

VehicleShowroomManagement/src/Application/Features/ServiceOrders/Queries/GetServiceOrders/GetServiceOrdersQueryHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task<ServiceOrdersResponse> Handle(GetServiceOrdersQuery request, C
5151
Description = so.Description,
5252
Cost = so.Cost,
5353
Type = so.Type.ToString(),
54-
Status = so.Status.ToString()
54+
Status = (int)so.Status
5555
}).ToList();
5656

5757
return new ServiceOrdersResponse

VehicleShowroomManagement/src/Application/Features/ServiceOrders/Queries/GetServiceOrders/ServiceOrderDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ServiceOrderDto
1414
public string? Description { get; set; }
1515
public decimal Cost { get; set; }
1616
public string Type { get; set; } = string.Empty;
17-
public string Status { get; set; } = string.Empty;
17+
public int Status { get; set; }
1818
}
1919

2020
/// <summary>

0 commit comments

Comments
 (0)