using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using System.Xml.Serialization;
using Jellyfin.Data.Enums;
namespace Jellyfin.Data.Entities
{
///
/// An entity representing a user's access schedule.
///
public class AccessSchedule
{
///
/// Initializes a new instance of the class.
///
/// The day of the week.
/// The start hour.
/// The end hour.
/// The associated user's id.
public AccessSchedule(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
{
UserId = userId;
DayOfWeek = dayOfWeek;
StartHour = startHour;
EndHour = endHour;
}
///
/// Initializes a new instance of the class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected AccessSchedule()
{
}
///
/// Gets or sets the id of this instance.
///
///
/// Identity, Indexed, Required.
///
[XmlIgnore]
[Key]
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the id of the associated user.
///
[XmlIgnore]
[Required]
public Guid UserId { get; protected set; }
///
/// Gets or sets the day of week.
///
/// The day of week.
[Required]
public DynamicDayOfWeek DayOfWeek { get; set; }
///
/// Gets or sets the start hour.
///
/// The start hour.
[Required]
public double StartHour { get; set; }
///
/// Gets or sets the end hour.
///
/// The end hour.
[Required]
public double EndHour { get; set; }
///
/// Static create function (for use in LINQ queries, etc.)
///
/// The day of the week.
/// The start hour.
/// The end hour.
/// The associated user's id.
/// The newly created instance.
public static AccessSchedule Create(DynamicDayOfWeek dayOfWeek, double startHour, double endHour, Guid userId)
{
return new AccessSchedule(dayOfWeek, startHour, endHour, userId);
}
}
}