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(1, int.MaxValue, ErrorMessage = "卡类型有误")]
public int CardType { get; set; }
///
/// 分配类型 DeviceTimePeriodAssignEnumType
///
[EnumDataType(typeof(DeviceTimePeriodAssignEnumType), ErrorMessage = "时段分配类型有误")]
public DeviceTimePeriodAssignEnumType AssignType { get; set; }
///
/// 分配值
///
[Required]
public Guid Value { get; set; }
///
/// 星期配置
///
[MinLength(7, ErrorMessage = "配置有误")]
[MaxLength(7, ErrorMessage = "配置有误")]
public List Sections { get; set; }
public IEnumerable Validate(ValidationContext validationContext)
{
if (Sections.DistinctBy(x => x.DayOfWeek).Count() != Sections.Count)
{
yield return new ValidationResult("星期配置重复", new[] { nameof(Sections) });
}
}
}