| | | 1 | | using MechanicsSoftware.Domain.Entities; |
| | | 2 | | using MechanicsSoftware.Domain.Enums; |
| | | 3 | | |
| | | 4 | | namespace MechanicsSoftware.Application.UseCases.ServiceOrders; |
| | | 5 | | |
| | | 6 | | public sealed record ServiceItemResponse( |
| | | 7 | | Guid Id, |
| | | 8 | | Guid ServiceId, |
| | | 9 | | string ServiceName, |
| | | 10 | | int UnitPriceInCents, |
| | | 11 | | int Quantity, |
| | | 12 | | int TotalInCents) |
| | | 13 | | { |
| | | 14 | | public static ServiceItemResponse From(ServiceItem item) => |
| | | 15 | | new(item.Id, item.ServiceId, item.ServiceName, |
| | | 16 | | item.UnitPrice.Cents, item.Quantity, item.Total.Cents); |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | public sealed record PartItemResponse( |
| | | 20 | | Guid Id, |
| | | 21 | | Guid PartId, |
| | | 22 | | string PartName, |
| | | 23 | | int UnitPriceInCents, |
| | | 24 | | int Quantity, |
| | | 25 | | string Availability, |
| | | 26 | | int TotalInCents) |
| | | 27 | | { |
| | | 28 | | public static PartItemResponse From(PartItem item) => |
| | | 29 | | new(item.Id, item.PartId, item.PartName, |
| | | 30 | | item.UnitPrice.Cents, item.Quantity, |
| | | 31 | | item.Availability == PartAvailability.Available ? "AVAILABLE" : "UNAVAILABLE", |
| | | 32 | | item.Total.Cents); |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | public sealed record BudgetResponse( |
| | | 36 | | Guid Id, |
| | | 37 | | int TotalInCents, |
| | | 38 | | string TotalFormatted, |
| | | 39 | | string Status, |
| | | 40 | | DateTime CreatedAt) |
| | | 41 | | { |
| | | 42 | | public static BudgetResponse From(Budget budget) => |
| | | 43 | | new(budget.Id, budget.Total.Cents, budget.Total.ToFormatted(), |
| | | 44 | | budget.Status.ToString(), budget.CreatedAt); |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | public sealed record ServiceOrderResponse( |
| | | 48 | | Guid Id, |
| | | 49 | | Guid CustomerId, |
| | | 50 | | Guid VehicleId, |
| | | 51 | | string Status, |
| | | 52 | | DateTime CreatedAt, |
| | | 53 | | DateTime? CompletedAt, |
| | | 54 | | DateTime? DeliveredAt, |
| | | 55 | | BudgetResponse? Budget, |
| | | 56 | | IReadOnlyList<ServiceItemResponse> ServiceItems, |
| | | 57 | | IReadOnlyList<PartItemResponse> PartItems) |
| | | 58 | | { |
| | | 59 | | public static ServiceOrderResponse From(ServiceOrder order) => |
| | | 60 | | new(order.Id, |
| | | 61 | | order.CustomerId, |
| | | 62 | | order.VehicleId, |
| | | 63 | | order.Status.ToString(), |
| | | 64 | | order.CreatedAt, |
| | | 65 | | order.CompletedAt, |
| | | 66 | | order.DeliveredAt, |
| | | 67 | | order.Budget is not null ? BudgetResponse.From(order.Budget) : null, |
| | | 68 | | order.ServiceItems.Select(ServiceItemResponse.From).ToList(), |
| | | 69 | | order.PartItems.Select(PartItemResponse.From).ToList()); |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | public sealed record ServiceOrderSummaryResponse( |
| | | 73 | | Guid Id, |
| | | 74 | | Guid CustomerId, |
| | | 75 | | Guid VehicleId, |
| | | 76 | | string Status, |
| | | 77 | | DateTime CreatedAt |
| | | 78 | | ); |
| | | 79 | | |
| | 2 | 80 | | public sealed record ServiceOrderStatusResponse( |
| | 2 | 81 | | Guid Id, |
| | 2 | 82 | | string Status, |
| | 2 | 83 | | DateTime CreatedAt, |
| | 2 | 84 | | DateTime? DeliveredAt |
| | 2 | 85 | | ); |
| | | 86 | | |
| | | 87 | | public sealed record AddPartItemResponse( |
| | | 88 | | Guid Id, |
| | | 89 | | Guid PartId, |
| | | 90 | | string PartName, |
| | | 91 | | int UnitPriceInCents, |
| | | 92 | | int Quantity, |
| | | 93 | | string Availability, |
| | | 94 | | int TotalInCents, |
| | | 95 | | string? Warning); |
| | | 96 | | |
| | | 97 | | public sealed record AverageExecutionTimeResponse( |
| | | 98 | | double AverageHours, |
| | | 99 | | int OrderCount |
| | | 100 | | ); |