我会将其表示为带有时间函数的开始和结束日期。
这是你的代码
public enum ActivityType
{
Swimming = 1,
Biking = 2,
Basketball = 3,
Soccer = 4
}
public class Booking
{
public DateTime BookingStart { get; set; }
public DateTime BookingEnd { get; set; }
public Activity Activity { get; set; }
public bool ValidateBooking()
{
// put logic here to ensure that the booking times fall within the activity start and end time
return true;
}
}
public class Activity
{
public ActivityType ActivityType { get; set; }
public DateTime ActivityStartTime { get; set; }
public DateTime ActivityEndTime { get; set; }
}
在您的数据库中,您将有一个包含此信息的表。
预订表
ID int
ActivityID int (foreign key to Activty.ID)
BookingStart DateTime
BookingEnd DateTime
活动表
ID int
ActivityType int
ActivityStartTime DateTime
ActivityEndTime DateTime