| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 3 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 4 | | |
| | | 5 | | namespace Jellyfin.Database.Implementations.Entities.Libraries |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// An entity representing a library. |
| | | 9 | | /// </summary> |
| | | 10 | | public class Library : IHasConcurrencyToken |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Initializes a new instance of the <see cref="Library"/> class. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="name">The name of the library.</param> |
| | | 16 | | /// <param name="path">The path of the library.</param> |
| | | 17 | | public Library(string name, string path) |
| | | 18 | | { |
| | 0 | 19 | | Name = name; |
| | 0 | 20 | | Path = path; |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets the id. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <remarks> |
| | | 27 | | /// Identity, Indexed, Required. |
| | | 28 | | /// </remarks> |
| | | 29 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 30 | | public int Id { get; private set; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets or sets the name. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <remarks> |
| | | 36 | | /// Required, Max length = 128. |
| | | 37 | | /// </remarks> |
| | | 38 | | [MaxLength(128)] |
| | | 39 | | [StringLength(128)] |
| | | 40 | | public string Name { get; set; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets or sets the root path of the library. |
| | | 44 | | /// </summary> |
| | | 45 | | /// <remarks> |
| | | 46 | | /// Required. |
| | | 47 | | /// </remarks> |
| | | 48 | | public string Path { get; set; } |
| | | 49 | | |
| | | 50 | | /// <inheritdoc /> |
| | | 51 | | [ConcurrencyCheck] |
| | | 52 | | public uint RowVersion { get; private set; } |
| | | 53 | | |
| | | 54 | | /// <inheritdoc /> |
| | | 55 | | public void OnSavingChanges() |
| | | 56 | | { |
| | 0 | 57 | | RowVersion++; |
| | 0 | 58 | | } |
| | | 59 | | } |
| | | 60 | | } |