using System.ComponentModel.DataAnnotations;
using Dlhis.Entity.Device.Enums;
namespace Dlhis.Basic.Device.Request;
public class DeviceTimePeriodSaveRequest : IValidatableObject
{
public long? Id { get; set; }
///
/// 卡类型 timeperiod
///
[Range(2, 3)]
public int CardType { get; set; }
///
/// 分配类型 DeviceTimePeriodAssignEnumType
///
[EnumDataType(typeof(DeviceTimePeriodAssignEnumType))]
public DeviceTimePeriodAssignEnumType AssignType { get; set; }
///
/// 分配值
///
[Required]
public Guid Value { get; set; }
///
/// 上班开始
///
[Required]
public TimeOnly OnStart { get; set; }
///
/// 上班结束
///
[Required]
public TimeOnly OnEnd { get; set; }
///
/// 下班开始
///
[Required]
public TimeOnly OffStart { get; set; }
///
/// 下班结束
///
[Required]
public TimeOnly OffEnd { get; set; }
///
public IEnumerable Validate(ValidationContext validationContext)
{
if (OnStart >= OnEnd)
{
yield return new ValidationResult("上班时段范围有误", new[] { nameof(OnStart) });
}
if (OffStart >= OffEnd)
{
yield return new ValidationResult("下班时段范围有误", new[] { nameof(OffStart) });
}
if (OnEnd >= OffStart)
{
yield return new ValidationResult("上下班时段范围有误", new[] { nameof(OnEnd) });
}
}
}