| | | 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 | | { |
| | | 8 | | public double? CustomX { get; set; } |
| | | 9 | | |
| | | 10 | | public double? CustomY { get; set; } |
| | | 11 | | |
| | | 12 | | public double? CustomRotation { get; set; } |
| | | 13 | | |
| | | 14 | | public int? WaypointId { get; set; } |
| | | 15 | | |
| | | 16 | | [Required (ErrorMessage = "Please enter the order.")] |
| | | 17 | | public required int Order { get; set; } |
| | | 18 | | |
| | | 19 | | public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) |
| | | 20 | | { |
| | | 21 | | if (WaypointId == null && CustomX == null && CustomY == null && CustomRotation == null) |
| | | 22 | | { |
| | | 23 | | yield return new ValidationResult("Please enter a waypoint or a custom coordinate.", [nameof(AutoTaskCreateDto.Aut |
| | | 24 | | } |
| | | 25 | | } |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | public static class AutoTaskDetailCreateDtoExtensions |
| | | 29 | | { |
| | | 30 | | public static AutoTaskDetailCreateBusinessModel ToBusinessModel(this AutoTaskDetailCreateDto model) |
| | 0 | 31 | | { |
| | 0 | 32 | | return new AutoTaskDetailCreateBusinessModel { |
| | 0 | 33 | | CustomX = model.CustomX, |
| | 0 | 34 | | CustomY = model.CustomY, |
| | 0 | 35 | | CustomRotation = model.CustomRotation, |
| | 0 | 36 | | WaypointId = model.WaypointId, |
| | 0 | 37 | | Order = model.Order, |
| | 0 | 38 | | }; |
| | 0 | 39 | | } |
| | | 40 | | } |