aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Data/Entities/Libraries/PersonRole.cs
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-08-30 18:50:54 -0400
committerPatrick Barron <barronpm@gmail.com>2020-08-30 18:51:31 -0400
commitacb213e4b8edf1c55f615fa8d0079f0fb7fdea68 (patch)
tree7ce91e5269da6847b04631071e6f8a1a3355c56d /Jellyfin.Data/Entities/Libraries/PersonRole.cs
parent414bedbde4b6c522d46ed7448eb9f7c97aeda4b4 (diff)
First pass at cleaning entity classes.
- Documents all library entities - Fixes styling warnings for library entities - Updates library entities to inherit from interfaces - Makes library entites no longer partial.
Diffstat (limited to 'Jellyfin.Data/Entities/Libraries/PersonRole.cs')
-rw-r--r--Jellyfin.Data/Entities/Libraries/PersonRole.cs215
1 files changed, 48 insertions, 167 deletions
diff --git a/Jellyfin.Data/Entities/Libraries/PersonRole.cs b/Jellyfin.Data/Entities/Libraries/PersonRole.cs
index 04d50deaf7..5290228d6e 100644
--- a/Jellyfin.Data/Entities/Libraries/PersonRole.cs
+++ b/Jellyfin.Data/Entities/Libraries/PersonRole.cs
@@ -1,217 +1,98 @@
-#pragma warning disable CS1591
-
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Jellyfin.Data.Enums;
+using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
- public partial class PersonRole
+ /// <summary>
+ /// An entity representing a person's role in media.
+ /// </summary>
+ public class PersonRole : IHasArtwork, IHasConcurrencyToken
{
- partial void Init();
-
/// <summary>
- /// Default constructor. Protected due to required properties, but present because EF needs it.
+ /// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary>
- protected PersonRole()
+ /// <param name="type">The role type.</param>
+ /// <param name="metadata">The metadata.</param>
+ public PersonRole(PersonRoleType type, Metadata metadata)
{
- // NOTE: This class has one-to-one associations with PersonRole.
- // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
-
- Sources = new HashSet<MetadataProviderId>();
+ Type = type;
- Init();
- }
-
- /// <summary>
- /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
- /// </summary>
- public static PersonRole CreatePersonRoleUnsafe()
- {
- return new PersonRole();
- }
-
- /// <summary>
- /// Public constructor with required data.
- /// </summary>
- /// <param name="type"></param>
- /// <param name="_metadata0"></param>
- public PersonRole(Enums.PersonRoleType type, Metadata _metadata0)
- {
- // NOTE: This class has one-to-one associations with PersonRole.
- // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
-
- this.Type = type;
-
- if (_metadata0 == null)
+ if (metadata == null)
{
- throw new ArgumentNullException(nameof(_metadata0));
+ throw new ArgumentNullException(nameof(metadata));
}
- _metadata0.PersonRoles.Add(this);
-
- this.Sources = new HashSet<MetadataProviderId>();
+ metadata.PersonRoles.Add(this);
- Init();
+ Sources = new HashSet<MetadataProviderId>();
}
/// <summary>
- /// Static create function (for use in LINQ queries, etc.)
+ /// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary>
- /// <param name="type"></param>
- /// <param name="_metadata0"></param>
- public static PersonRole Create(Enums.PersonRoleType type, Metadata _metadata0)
+ /// <remarks>
+ /// Default constructor. Protected due to required properties, but present because EF needs it.
+ /// </remarks>
+ protected PersonRole()
{
- return new PersonRole(type, _metadata0);
}
- /*************************************************************************
- * Properties
- *************************************************************************/
-
- /// <summary>
- /// Backing field for Id.
- /// </summary>
- internal int _Id;
- /// <summary>
- /// When provided in a partial class, allows value of Id to be changed before setting.
- /// </summary>
- partial void SetId(int oldValue, ref int newValue);
/// <summary>
- /// When provided in a partial class, allows value of Id to be changed before returning.
+ /// Gets or sets the id.
/// </summary>
- partial void GetId(ref int result);
-
- /// <summary>
+ /// <remarks>
/// Identity, Indexed, Required.
- /// </summary>
- [Key]
- [Required]
+ /// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int Id
- {
- get
- {
- int value = _Id;
- GetId(ref value);
- return _Id = value;
- }
-
- protected set
- {
- int oldValue = _Id;
- SetId(oldValue, ref value);
- if (oldValue != value)
- {
- _Id = value;
- }
- }
- }
-
- /// <summary>
- /// Backing field for Role.
- /// </summary>
- protected string _Role;
- /// <summary>
- /// When provided in a partial class, allows value of Role to be changed before setting.
- /// </summary>
- partial void SetRole(string oldValue, ref string newValue);
- /// <summary>
- /// When provided in a partial class, allows value of Role to be changed before returning.
- /// </summary>
- partial void GetRole(ref string result);
+ public int Id { get; protected set; }
/// <summary>
- /// Max length = 1024
+ /// Gets or sets the name of the person's role.
/// </summary>
+ /// <remarks>
+ /// Max length = 1024.
+ /// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
- public string Role
- {
- get
- {
- string value = _Role;
- GetRole(ref value);
- return _Role = value;
- }
-
- set
- {
- string oldValue = _Role;
- SetRole(oldValue, ref value);
- if (oldValue != value)
- {
- _Role = value;
- }
- }
- }
+ public string Role { get; set; }
/// <summary>
- /// Backing field for Type.
+ /// Gets or sets the person's role type.
/// </summary>
- protected Enums.PersonRoleType _Type;
- /// <summary>
- /// When provided in a partial class, allows value of Type to be changed before setting.
- /// </summary>
- partial void SetType(Enums.PersonRoleType oldValue, ref Enums.PersonRoleType newValue);
- /// <summary>
- /// When provided in a partial class, allows value of Type to be changed before returning.
- /// </summary>
- partial void GetType(ref Enums.PersonRoleType result);
+ /// <remarks>
+ /// Required.
+ /// </remarks>
+ public PersonRoleType Type { get; set; }
+
+ /// <inheritdoc />
+ [ConcurrencyCheck]
+ public uint RowVersion { get; protected set; }
/// <summary>
- /// Required.
+ /// Gets or sets the person.
/// </summary>
+ /// <remarks>
+ /// Required.
+ /// </remarks>
[Required]
- public Enums.PersonRoleType Type
- {
- get
- {
- Enums.PersonRoleType value = _Type;
- GetType(ref value);
- return _Type = value;
- }
+ public virtual Person Person { get; set; }
- set
- {
- Enums.PersonRoleType oldValue = _Type;
- SetType(oldValue, ref value);
- if (oldValue != value)
- {
- _Type = value;
- }
- }
- }
+ /// <inheritdoc />
+ public virtual ICollection<Artwork> Artwork { get; protected set; }
/// <summary>
- /// Required, ConcurrenyToken.
+ /// Gets or sets a collection containing the metadata sources for this person role.
/// </summary>
- [ConcurrencyCheck]
- [Required]
- public uint RowVersion { get; set; }
+ public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
+ /// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
}
-
- /*************************************************************************
- * Navigation properties
- *************************************************************************/
-
- /// <summary>
- /// Required.
- /// </summary>
- [ForeignKey("Person_Id")]
-
- public virtual Person Person { get; set; }
-
- [ForeignKey("Artwork_Artwork_Id")]
- public virtual Artwork Artwork { get; set; }
-
- [ForeignKey("MetadataProviderId_Sources_Id")]
- public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
}
}
-