37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Text.Json;
 | |
| 
 | |
| namespace OI.Metrology.Shared.ViewModels;
 | |
| 
 | |
| // [JsonConstructor]
 | |
| public record ServiceShopOrder(string Id,
 | |
|                                string Name,
 | |
|                                string[] BookingNames,
 | |
|                                string Type,
 | |
|                                string State,
 | |
|                                string ItemNumber,
 | |
|                                DateTime CreatedDate,
 | |
|                                DateTime DecidedDate,
 | |
|                                string Recipient,
 | |
|                                string Requestor)
 | |
| {
 | |
| 
 | |
|     internal ServiceShopOrder(Models.Order order) :
 | |
|         this(order.Id,
 | |
|              order.Name,
 | |
|              order.Bookings is null || !order.Bookings.Any() ? Array.Empty<string>() : order.Bookings.Select(l => l.Name).ToArray(),
 | |
|              order.Type,
 | |
|              order.State,
 | |
|              order.ItemNumber,
 | |
|              order.CreatedDate,
 | |
|              order.DecidedDate,
 | |
|              order.Recipient,
 | |
|              order.Requestor)
 | |
|     { }
 | |
| 
 | |
|     public override string ToString()
 | |
|     {
 | |
|         string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
 | |
|         return result;
 | |
|     }
 | |
| 
 | |
| } |