2024-09-18 12:59:25 +05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Requests;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// класс с фильтрами для запроса
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SubsystemBaseRequest: RequestBase, IValidatableObject
|
|
|
|
|
{
|
2024-09-30 09:56:34 +05:00
|
|
|
|
public static readonly DateTimeOffset ValidationMinDate = new DateTimeOffset(2020,01,01,0,0,0, TimeSpan.Zero);
|
2024-09-18 12:59:25 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Больше или равно дате
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTimeOffset? GeDate { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Меньше или равно дате
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTimeOffset? LeDate { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Больше или равно глубины забоя
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double? GeDepth { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Меньше или равно глубины забоя
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double? LeDepth { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
|
|
|
{
|
2024-09-30 09:56:34 +05:00
|
|
|
|
if (GeDate.HasValue && GeDate < ValidationMinDate)
|
2024-09-18 12:59:25 +05:00
|
|
|
|
yield return new ValidationResult(
|
2024-09-30 09:56:34 +05:00
|
|
|
|
$"Должно быть больше {ValidationMinDate:O})",
|
2024-09-18 12:59:25 +05:00
|
|
|
|
new[] { nameof(GeDate) });
|
|
|
|
|
|
|
|
|
|
if (LeDate.HasValue && GeDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (LeDate < GeDate)
|
|
|
|
|
yield return new ValidationResult(
|
|
|
|
|
$"{nameof(LeDate)} должно быть больше {nameof(GeDate)}. ({LeDate:O} < {GeDate:O})",
|
|
|
|
|
new[] { nameof(LeDate), nameof(GeDate) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (LeDepth.HasValue && GeDepth.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (LeDepth < GeDepth)
|
|
|
|
|
yield return new ValidationResult(
|
|
|
|
|
$"{nameof(LeDepth)} должно быть больше {nameof(GeDepth)}. ({LeDepth} < {GeDepth})",
|
|
|
|
|
new[] { nameof(LeDepth), nameof(GeDepth) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
}
|