using System.ComponentModel.DataAnnotations;
using Dlhis.Entity.Canteen.Enums;
using Kurisu.AspNetCore.CustomClass;
namespace Dlhis.Basic.BusinessShift.Request;
public class BusinessPlaceShiftSaveMealShiftRequest : IValidatableObject
{
public long? Id { get; set; }
///
/// 餐别Code
///
public Guid ShiftCode { get; set; }
///
/// 餐次 ShiftEnumType
///
[EnumDataType(typeof(ShiftEnumType))]
public ShiftEnumType ShiftType { get; set; }
///
/// 序号
///
public int Sequence { get; set; } = 100;
///
/// 时间段
///
[Required(ErrorMessage = "时间段不可为空")]
public TimePeriod TimePeriod { get; set; }
public IEnumerable Validate(ValidationContext validationContext)
{
if (TimePeriod == null)
{
yield return new ValidationResult("时间段配置错误", new[] { nameof(TimePeriod) });
}
if (TimePeriod!.Start == TimePeriod.End)
{
yield return new ValidationResult("时间段设置区间有误,开始时段不能等于结束时段.", new[] { nameof(TimePeriod) });
}
}
}