< Summary

Information
Class: LGDXRobotCloud.Data.Models.DTOs.V1.Commands.TriggerCreateDto
Assembly: LGDXRobotCloud.Data
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.Data/Models/DTOs/V1/Commands/TriggerCreateDto.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 24
Coverable lines: 24
Total lines: 62
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 12
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%210%
get_Url()100%210%
get_HttpMethodId()100%210%
get_Body()100%210%
get_ApiKeyInsertLocationId()100%210%
get_ApiKeyFieldName()100%210%
get_ApiKeyId()100%210%
Validate()0%156120%

File(s)

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

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using LGDXRobotCloud.Data.Models.Business.Automation;
 3
 4namespace LGDXRobotCloud.Data.Models.DTOs.V1.Commands;
 5
 6public record TriggerCreateDto
 7{
 8  [Required (ErrorMessage = "Please enter a name.")]
 9  [MaxLength(50)]
 010  public required string Name { get; set; }
 11
 12  [Required (ErrorMessage = "Please enter an URL.")]
 13  [MaxLength(200)]
 014  public required string Url { get; set; }
 15
 016  public required int HttpMethodId { get; set; }
 17
 018  public string? Body { get; set; }
 19
 20
 021  public int? ApiKeyInsertLocationId { get; set; }
 22
 23  [MaxLength(50)]
 024  public string? ApiKeyFieldName { get; set; }
 25
 026  public int? ApiKeyId { get; set; }
 27
 28  public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
 029  {
 030    if (!(ApiKeyInsertLocationId != null && ApiKeyFieldName != null && ApiKeyId != null))
 031    {
 032      if (ApiKeyInsertLocationId == null)
 033      {
 034        yield return new ValidationResult("Please select an insert location.", [nameof(ApiKeyInsertLocationId)]);
 035      }
 036      if (ApiKeyFieldName == null)
 037      {
 038        yield return new ValidationResult("Please enter a field name.", [nameof(ApiKeyFieldName)]);
 039      }
 040      if (ApiKeyId == null)
 041      {
 042        yield return new ValidationResult("Please select an API Key.", [nameof(ApiKeyId)]);
 043      }
 044    }
 045  }
 46}
 47
 48public static class TriggerCreateDtoExtensions
 49{
 50  public static TriggerCreateBusinessModel ToBusinessModel(this TriggerCreateDto triggerCreateDto)
 51  {
 52    return new TriggerCreateBusinessModel {
 53      Name = triggerCreateDto.Name,
 54      Url = triggerCreateDto.Url,
 55      HttpMethodId = triggerCreateDto.HttpMethodId,
 56      Body = triggerCreateDto.Body,
 57      ApiKeyInsertLocationId = triggerCreateDto.ApiKeyInsertLocationId,
 58      ApiKeyFieldName = triggerCreateDto.ApiKeyFieldName,
 59      ApiKeyId = triggerCreateDto.ApiKeyId,
 60    };
 61  }
 62}