mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Clean up Group.cs
This commit is contained in:
parent
b24221b40f
commit
d0f07d7ddd
@ -1,9 +1,6 @@
|
|||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Data.Interfaces;
|
using Jellyfin.Data.Interfaces;
|
||||||
@ -13,11 +10,10 @@ namespace Jellyfin.Data.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An entity representing a group.
|
/// An entity representing a group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Group : IHasPermissions, IHasConcurrencyToken
|
public class Group : IHasPermissions, IHasConcurrencyToken
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Group"/> class.
|
/// Initializes a new instance of the <see cref="Group"/> class.
|
||||||
/// Public constructor with required data.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the group.</param>
|
/// <param name="name">The name of the group.</param>
|
||||||
public Group(string name)
|
public Group(string name)
|
||||||
@ -32,31 +28,24 @@ namespace Jellyfin.Data.Entities
|
|||||||
|
|
||||||
Permissions = new HashSet<Permission>();
|
Permissions = new HashSet<Permission>();
|
||||||
Preferences = new HashSet<Preference>();
|
Preferences = new HashSet<Preference>();
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Group"/> class.
|
/// Initializes a new instance of the <see cref="Group"/> class.
|
||||||
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
||||||
|
/// </remarks>
|
||||||
protected Group()
|
protected Group()
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* Properties
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the id of this group.
|
/// Gets or sets the id of this group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Identity, Indexed, Required.
|
/// Identity, Indexed, Required.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Key]
|
|
||||||
[Required]
|
|
||||||
public Guid Id { get; protected set; }
|
public Guid Id { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -70,39 +59,19 @@ namespace Jellyfin.Data.Entities
|
|||||||
[StringLength(255)]
|
[StringLength(255)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets or sets the row version.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Required, Concurrency Token.
|
|
||||||
/// </remarks>
|
|
||||||
[ConcurrencyCheck]
|
[ConcurrencyCheck]
|
||||||
[Required]
|
|
||||||
public uint RowVersion { get; set; }
|
public uint RowVersion { get; set; }
|
||||||
|
|
||||||
public void OnSavingChanges()
|
/// <summary>
|
||||||
{
|
/// Gets or sets a collection containing the group's permissions.
|
||||||
RowVersion++;
|
/// </summary>
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* Navigation properties
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
[ForeignKey("Permission_GroupPermissions_Id")]
|
|
||||||
public virtual ICollection<Permission> Permissions { get; protected set; }
|
public virtual ICollection<Permission> Permissions { get; protected set; }
|
||||||
|
|
||||||
[ForeignKey("Preference_Preferences_Id")]
|
|
||||||
public virtual ICollection<Preference> Preferences { get; protected set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Static create function (for use in LINQ queries, etc.)
|
/// Gets or sets a collection containing the group's preferences.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of this group.</param>
|
public virtual ICollection<Preference> Preferences { get; protected set; }
|
||||||
public static Group Create(string name)
|
|
||||||
{
|
|
||||||
return new Group(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool HasPermission(PermissionKind kind)
|
public bool HasPermission(PermissionKind kind)
|
||||||
@ -116,6 +85,10 @@ namespace Jellyfin.Data.Entities
|
|||||||
Permissions.First(p => p.Kind == kind).Value = value;
|
Permissions.First(p => p.Kind == kind).Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void Init();
|
/// <inheritdoc />
|
||||||
|
public void OnSavingChanges()
|
||||||
|
{
|
||||||
|
RowVersion++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user