< Summary

Information
Class: LGDXRobotCloud.Data.Models.DTOs.V1.Commands.TriggerUpdateDto
Assembly: LGDXRobotCloud.Data
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.Data/Models/DTOs/V1/Commands/TriggerUpdateDto.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 64
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_SkipOnFailure()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/TriggerUpdateDto.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using LGDXRobotCloud.Data.Models.Business.Automation;
 3
 4namespace LGDXRobotCloud.Data.Models.DTOs.V1.Commands;
 5
 6public record TriggerUpdateDto : IValidatableObject
 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
 020  public required bool SkipOnFailure { get; set; } = false;
 21
 022  public int? ApiKeyInsertLocationId { get; set; }
 23
 24  [MaxLength(50)]
 025  public string? ApiKeyFieldName { get; set; }
 26
 027  public int? ApiKeyId { get; set; }
 28
 29  public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
 030  {
 031    if (!(ApiKeyInsertLocationId == null && string.IsNullOrWhiteSpace(ApiKeyFieldName) && ApiKeyId == null))
 032    {
 033      if (ApiKeyInsertLocationId == null)
 034      {
 035        yield return new ValidationResult("Please select an insert location.", [nameof(ApiKeyInsertLocationId)]);
 036      }
 037      if (ApiKeyFieldName == null)
 038      {
 039        yield return new ValidationResult("Please enter a field name.", [nameof(ApiKeyFieldName)]);
 040      }
 041      if (ApiKeyId == null)
 042      {
 043        yield return new ValidationResult("Please select an API Key.", [nameof(ApiKeyId)]);
 044      }
 045    }
 046  }
 47}
 48
 49public static class TriggerUpdateDtoExtensions
 50{
 51  public static TriggerUpdateBusinessModel ToBusinessModel(this TriggerUpdateDto triggerUpdateDto)
 52  {
 53    return new TriggerUpdateBusinessModel {
 54      Name = triggerUpdateDto.Name,
 55      Url = triggerUpdateDto.Url,
 56      HttpMethodId = triggerUpdateDto.HttpMethodId,
 57      Body = triggerUpdateDto.Body,
 58      SkipOnFailure = triggerUpdateDto.SkipOnFailure,
 59      ApiKeyInsertLocationId = triggerUpdateDto.ApiKeyInsertLocationId,
 60      ApiKeyFieldName = triggerUpdateDto.ApiKeyFieldName,
 61      ApiKeyId = triggerUpdateDto.ApiKeyId,
 62    };
 63  }
 64}