| | 1 | | using System.ComponentModel.DataAnnotations; |
| | 2 | | using LGDXRobotCloud.Data.Models.Business.Automation; |
| | 3 | |
|
| | 4 | | namespace LGDXRobotCloud.Data.Models.DTOs.V1.Commands; |
| | 5 | |
|
| | 6 | | public record AutoTaskDetailCreateDto : IValidatableObject |
| | 7 | | { |
| 0 | 8 | | public double? CustomX { get; set; } |
| | 9 | |
|
| 0 | 10 | | public double? CustomY { get; set; } |
| | 11 | |
|
| 0 | 12 | | public double? CustomRotation { get; set; } |
| | 13 | |
|
| 0 | 14 | | public int? WaypointId { get; set; } |
| | 15 | |
|
| | 16 | | [Required (ErrorMessage = "Please enter the order.")] |
| 0 | 17 | | public required int Order { get; set; } |
| | 18 | |
|
| | 19 | | public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) |
| 0 | 20 | | { |
| 0 | 21 | | if (WaypointId == null && CustomX == null && CustomY == null && CustomRotation == null) |
| 0 | 22 | | { |
| 0 | 23 | | yield return new ValidationResult("Please enter a waypoint or a custom coordinate.", [nameof(AutoTaskCreateDto.Aut |
| 0 | 24 | | } |
| 0 | 25 | | } |
| | 26 | | } |
| | 27 | |
|
| | 28 | | public static class AutoTaskDetailCreateDtoExtensions |
| | 29 | | { |
| | 30 | | public static AutoTaskDetailCreateBusinessModel ToBusinessModel(this AutoTaskDetailCreateDto model) |
| | 31 | | { |
| | 32 | | return new AutoTaskDetailCreateBusinessModel { |
| | 33 | | CustomX = model.CustomX, |
| | 34 | | CustomY = model.CustomY, |
| | 35 | | CustomRotation = model.CustomRotation, |
| | 36 | | WaypointId = model.WaypointId, |
| | 37 | | Order = model.Order, |
| | 38 | | }; |
| | 39 | | } |
| | 40 | | } |