PosResQueryDto.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace XdCxRhDw.Dto
  8. {
  9. /// <summary>
  10. /// 定位结果查询参数模型
  11. /// </summary>
  12. public class PosResQueryDto:IValidatableObject
  13. {
  14. /// <summary>
  15. /// 任务编号
  16. /// </summary>
  17. [RangeInt(0)]
  18. public int TaskInfoID { get; set; }
  19. /// <summary>
  20. /// 开始时间
  21. /// </summary>
  22. public DateTime BeginTime { get; set; }
  23. /// <summary>
  24. /// 结束时间
  25. /// </summary>
  26. public DateTime EndTime { get; set; }
  27. /// <summary>
  28. ///
  29. /// </summary>
  30. /// <param name="validationContext"></param>
  31. /// <returns></returns>
  32. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  33. {
  34. if ((EndTime - BeginTime).TotalDays > 10)
  35. yield return new ValidationResult("时间跨度不能超过10天!", new[] { nameof(BeginTime),nameof(EndTime) });
  36. }
  37. }
  38. }