2019-06-01 20:40:01 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
namespace Jellyfin.Data.Entities
|
|
|
|
{
|
2020-05-15 21:24:01 +00:00
|
|
|
public partial class Group : IHasPermissions, ISavingChanges
|
2020-05-02 21:56:05 +00:00
|
|
|
{
|
|
|
|
partial void Init();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
|
|
|
/// </summary>
|
|
|
|
protected Group()
|
|
|
|
{
|
2020-05-15 21:24:01 +00:00
|
|
|
Permissions = new HashSet<Permission>();
|
2020-05-02 21:56:05 +00:00
|
|
|
ProviderMappings = new HashSet<ProviderMapping>();
|
|
|
|
Preferences = new HashSet<Preference>();
|
|
|
|
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Public constructor with required data
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="name"></param>
|
2020-05-15 21:24:01 +00:00
|
|
|
/// <param name="user"></param>
|
|
|
|
public Group(string name, User user)
|
2020-05-02 21:56:05 +00:00
|
|
|
{
|
2020-05-15 21:24:01 +00:00
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
{
|
|
|
|
throw new ArgumentNullException(nameof(name));
|
|
|
|
}
|
2020-05-02 21:56:05 +00:00
|
|
|
|
2020-05-15 21:24:01 +00:00
|
|
|
this.Name = name;
|
|
|
|
user.Groups.Add(this);
|
2020-05-02 21:56:05 +00:00
|
|
|
|
2020-05-15 21:24:01 +00:00
|
|
|
this.Permissions = new HashSet<Permission>();
|
2020-05-02 21:56:05 +00:00
|
|
|
this.ProviderMappings = new HashSet<ProviderMapping>();
|
|
|
|
this.Preferences = new HashSet<Preference>();
|
|
|
|
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Static create function (for use in LINQ queries, etc.)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="name"></param>
|
|
|
|
/// <param name="_user0"></param>
|
2020-05-15 21:24:01 +00:00
|
|
|
public static Group Create(string name, User user)
|
2020-05-02 21:56:05 +00:00
|
|
|
{
|
2020-05-15 21:24:01 +00:00
|
|
|
return new Group(name, user);
|
2020-05-02 21:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Properties
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Identity, Indexed, Required
|
|
|
|
/// </summary>
|
|
|
|
[Key]
|
|
|
|
[Required]
|
2020-05-15 21:24:01 +00:00
|
|
|
public Guid Id { get; protected set; }
|
2020-05-02 21:56:05 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Required, Max length = 255
|
|
|
|
/// </summary>
|
|
|
|
[Required]
|
|
|
|
[MaxLength(255)]
|
|
|
|
[StringLength(255)]
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Required, ConcurrenyToken
|
|
|
|
/// </summary>
|
|
|
|
[ConcurrencyCheck]
|
|
|
|
[Required]
|
|
|
|
public uint RowVersion { get; set; }
|
|
|
|
|
|
|
|
public void OnSavingChanges()
|
|
|
|
{
|
|
|
|
RowVersion++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Navigation properties
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
[ForeignKey("Permission_GroupPermissions_Id")]
|
2020-05-19 23:05:17 +00:00
|
|
|
public virtual ICollection<Permission> Permissions { get; protected set; }
|
2020-05-02 21:56:05 +00:00
|
|
|
|
|
|
|
[ForeignKey("ProviderMapping_ProviderMappings_Id")]
|
2020-05-19 23:05:17 +00:00
|
|
|
public virtual ICollection<ProviderMapping> ProviderMappings { get; protected set; }
|
2020-05-02 21:56:05 +00:00
|
|
|
|
|
|
|
[ForeignKey("Preference_Preferences_Id")]
|
2020-05-19 23:05:17 +00:00
|
|
|
public virtual ICollection<Preference> Preferences { get; protected set; }
|
2020-05-02 21:56:05 +00:00
|
|
|
}
|
2019-06-01 20:40:01 +00:00
|
|
|
}
|
|
|
|
|