|  |  | 1 |  | using System.ComponentModel.DataAnnotations; | 
|  |  | 2 |  | using LGDXRobotCloud.Data.Models.Business.Administration; | 
|  |  | 3 |  |  | 
|  |  | 4 |  | namespace LGDXRobotCloud.Data.Models.DTOs.V1.Commands; | 
|  |  | 5 |  |  | 
|  |  | 6 |  | public record LgdxRoleUpdateDto : IValidatableObject | 
|  |  | 7 |  | { | 
|  |  | 8 |  |   [Required (ErrorMessage = "Please enter a name.")] | 
|  | 0 | 9 |  |   public required string Name { get; set; } | 
|  |  | 10 |  |  | 
|  | 0 | 11 |  |   public string? Description { get; set; } | 
|  |  | 12 |  |  | 
|  | 0 | 13 |  |   public IEnumerable<string> Scopes { get; set; } = []; // Empty scope is allowed | 
|  |  | 14 |  |  | 
|  |  | 15 |  |   public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) | 
|  | 0 | 16 |  |   { | 
|  | 0 | 17 |  |     int i = 0; | 
|  | 0 | 18 |  |     foreach (var scope in Scopes) | 
|  | 0 | 19 |  |     { | 
|  | 0 | 20 |  |       if (string.IsNullOrWhiteSpace(scope)) | 
|  | 0 | 21 |  |       { | 
|  | 0 | 22 |  |         yield return new ValidationResult($"Scope is required.", [nameof(Scopes), $"{nameof(Scopes)}-{i}"]); | 
|  | 0 | 23 |  |       } | 
|  | 0 | 24 |  |       i++; | 
|  | 0 | 25 |  |     } | 
|  | 0 | 26 |  |   } | 
|  |  | 27 |  | } | 
|  |  | 28 |  |  | 
|  |  | 29 |  | public static class LgdxRoleUpdateDtoExtensions | 
|  |  | 30 |  | { | 
|  |  | 31 |  |   public static LgdxRoleUpdateBusinessModel ToBusinessModel(this LgdxRoleUpdateDto model) | 
|  |  | 32 |  |   { | 
|  |  | 33 |  |     return new LgdxRoleUpdateBusinessModel | 
|  |  | 34 |  |     { | 
|  |  | 35 |  |       Name = model.Name, | 
|  |  | 36 |  |       Description = model.Description, | 
|  |  | 37 |  |       Scopes = model.Scopes, | 
|  |  | 38 |  |     }; | 
|  |  | 39 |  |   } | 
|  |  | 40 |  | } |