< Summary

Information
Class: LGDXRobotCloud.Data.Models.DTOs.V1.Commands.FlowCreateDtoExtensions
Assembly: LGDXRobotCloud.Data
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.Data/Models/DTOs/V1/Commands/FlowCreateDto.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 37
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToBusinessModel(...)100%210%

File(s)

/builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.Data/Models/DTOs/V1/Commands/FlowCreateDto.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using LGDXRobotCloud.Data.Models.Business.Automation;
 3
 4namespace LGDXRobotCloud.Data.Models.DTOs.V1.Commands;
 5
 6public record FlowCreateDto : IValidatableObject
 7{
 8  [Required (ErrorMessage = "Please enter a name.")]
 9  public required string Name { get; set; }
 10
 11  public required IList<FlowDetailCreateDto> FlowDetails { get; set; } = [];
 12
 13  public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
 14  {
 15    foreach (var flow in FlowDetails)
 16    {
 17      List<ValidationResult> validationResults = [];
 18      var vc = new ValidationContext(flow);
 19      Validator.TryValidateObject(flow, vc, validationResults, true);
 20      foreach (var validationResult in validationResults)
 21      {
 22        yield return validationResult;
 23      }
 24    }
 25  }
 26}
 27
 28public static class FlowCreateDtoExtensions
 29{
 30  public static FlowCreateBusinessModel ToBusinessModel(this FlowCreateDto flowCreateDto)
 031  {
 032    return new FlowCreateBusinessModel {
 033      Name = flowCreateDto.Name,
 034      FlowDetails = flowCreateDto.FlowDetails.Select(fd => fd.ToBusinessModel()).ToList(),
 035    };
 036  }
 37}