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