2024-07-04 11:02:45 +05:00
|
|
|
|
using System;
|
2022-07-18 18:51:49 +05:00
|
|
|
|
using System.Collections.Generic;
|
2022-08-01 13:55:51 +05:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2022-07-18 18:51:49 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
namespace AsbCloudApp.Requests;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// класс с фильтрами для запроса
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SubsystemRequest: RequestBase, IValidatableObject
|
2022-07-18 18:51:49 +05:00
|
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
|
private static readonly DateTimeOffset validationMinDate = new DateTimeOffset(2020,01,01,0,0,0, TimeSpan.Zero);
|
|
|
|
|
|
2022-07-18 18:51:49 +05:00
|
|
|
|
/// <summary>
|
2024-08-19 10:01:07 +05:00
|
|
|
|
/// идентификатор скважины
|
2022-07-18 18:51:49 +05:00
|
|
|
|
/// </summary>
|
2024-08-19 10:01:07 +05:00
|
|
|
|
[Required]
|
|
|
|
|
public int IdWell { get; set; }
|
2023-09-28 16:25:29 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Идентификатор бурильщика
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int? IdDriller { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Больше или равно дате
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTimeOffset? GeDate { get; set; }
|
2023-09-28 16:25:29 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Меньше или равно дате
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTimeOffset? LeDate { get; set; }
|
2022-08-01 13:55:51 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Больше или равно глубины забоя
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double? GeDepth { get; set; }
|
2022-08-01 13:55:51 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Меньше или равно глубины забоя
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double? LeDepth { get; set; }
|
2022-08-01 13:55:51 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
|
|
|
{
|
|
|
|
|
if (GeDate.HasValue && GeDate < validationMinDate)
|
|
|
|
|
yield return new ValidationResult(
|
|
|
|
|
$"Должно быть больше {validationMinDate:O})",
|
|
|
|
|
new[] { nameof(GeDate) });
|
2022-08-01 13:55:51 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
if (LeDate.HasValue && GeDate.HasValue)
|
2023-09-28 16:25:29 +05:00
|
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
|
if (LeDate < GeDate)
|
2023-09-28 16:25:29 +05:00
|
|
|
|
yield return new ValidationResult(
|
2024-08-19 10:01:07 +05:00
|
|
|
|
$"{nameof(LeDate)} должно быть больше {nameof(GeDate)}. ({LeDate:O} < {GeDate:O})",
|
|
|
|
|
new[] { nameof(LeDate), nameof(GeDate) });
|
|
|
|
|
}
|
2023-09-28 16:25:29 +05:00
|
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
|
if (LeDepth.HasValue && GeDepth.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (LeDepth < GeDepth)
|
|
|
|
|
yield return new ValidationResult(
|
|
|
|
|
$"{nameof(LeDepth)} должно быть больше {nameof(GeDepth)}. ({LeDepth} < {GeDepth})",
|
|
|
|
|
new[] { nameof(LeDepth), nameof(GeDepth) });
|
2023-09-28 16:25:29 +05:00
|
|
|
|
}
|
2024-08-19 10:01:07 +05:00
|
|
|
|
|
|
|
|
|
yield break;
|
2022-07-18 18:51:49 +05:00
|
|
|
|
}
|
|
|
|
|
}
|