using System.ComponentModel.DataAnnotations; using Dlhis.Entity.Basic.Enums; namespace Dlhis.Basic.WorkGrids.Request; public class WorkGridScheduleSaveRequest : IValidatableObject { /// /// 网格code /// public Guid WorkGridCode { get; set; } /// /// 排班日期 /// public DateOnly Date { get; set; } /// /// 班次 /// [EnumDataType(typeof(WorkGridTimePeriodEnumType), ErrorMessage = "班次类型错误")] public WorkGridTimePeriodEnumType PeriodType { get; set; } /// /// 人员codes /// [MinLength(1, ErrorMessage = "人员不可为空")] public List UserCodes { get; set; } public IEnumerable Validate(ValidationContext validationContext) { var now = DateTime.Now; if (Date.ToDateTime(new TimeOnly(0, 0)) < now.Date) { yield return new ValidationResult("不可编辑历史数据", new[] { nameof(Date) }); } } }