XML Documentation Pass

This commit is contained in:
REDCODE
2024-11-10 20:14:55 +01:00
parent 58204f23dd
commit 1b179abc50
9 changed files with 275 additions and 29 deletions

View File

@@ -4,7 +4,16 @@ using Lactose.Types;
namespace Lactose.Mapper; namespace Lactose.Mapper;
/// <summary>
/// Provides mapping methods for converting Asset objects to DTOs.
/// </summary>
public static class AssetsMapper { public static class AssetsMapper {
/// <summary>
/// Maps an Asset object to a GetFullAssetDto object.
/// </summary>
/// <param name="asset">The asset to map.</param>
/// <param name="accessLevel">The access level of the user.</param>
/// <returns>A GetFullAssetDto object.</returns>
public static GetFullAssetDto ToFullAssetsDto(this Asset asset, EAccessLevel accessLevel) => new GetFullAssetDto { public static GetFullAssetDto ToFullAssetsDto(this Asset asset, EAccessLevel accessLevel) => new GetFullAssetDto {
Id = asset.Id, Id = asset.Id,
FileName = accessLevel >= EAccessLevel.Curator ? asset.OriginalFilename : null, FileName = accessLevel >= EAccessLevel.Curator ? asset.OriginalFilename : null,
@@ -16,10 +25,20 @@ public static class AssetsMapper {
Owner = asset.Owner!.ToGetUsersDto() Owner = asset.Owner!.ToGetUsersDto()
}; };
/// <summary>
/// Maps an Asset object to a GetAssetPreviewDto object.
/// </summary>
/// <param name="asset">The asset to map.</param>
/// <returns>A GetAssetPreviewDto object.</returns>
public static GetAssetPreviewDto ToAssetPreviewDto(this Asset asset) => new GetAssetPreviewDto { public static GetAssetPreviewDto ToAssetPreviewDto(this Asset asset) => new GetAssetPreviewDto {
Id = asset.Id Id = asset.Id
}; };
/// <summary>
/// Maps a collection of Asset objects to a collection of GetAssetPreviewDto objects.
/// </summary>
/// <param name="assets">The collection of assets to map.</param>
/// <returns>A collection of GetAssetPreviewDto objects.</returns>
public static IEnumerable<GetAssetPreviewDto> ToAssetPreviewDto(this IEnumerable<Asset> assets) public static IEnumerable<GetAssetPreviewDto> ToAssetPreviewDto(this IEnumerable<Asset> assets)
=> assets.Select(ToAssetPreviewDto); => assets.Select(ToAssetPreviewDto);
} }

View File

@@ -5,7 +5,15 @@ using Lactose.Models;
namespace Lactose.Mapper; namespace Lactose.Mapper;
/// <summary>
/// Provides methods for mapping Tag objects to TagDto objects.
/// </summary>
public static class TagsMapper { public static class TagsMapper {
/// <summary>
/// Maps a Tag object to a TagDto object.
/// </summary>
/// <param name="tag">The Tag object to map.</param>
/// <returns>A TagDto object.</returns>
public static TagDto ToTagDto(Tag tag) { public static TagDto ToTagDto(Tag tag) {
return new TagDto() { return new TagDto() {
Id = tag.Id, Id = tag.Id,
@@ -13,4 +21,4 @@ public static class TagsMapper {
Parent = null Parent = null
}; };
} }
} }

View File

@@ -4,7 +4,15 @@ using Lactose.Models;
namespace Lactose.Mapper; namespace Lactose.Mapper;
/// <summary>
/// Provides mapping methods for User objects.
/// </summary>
public static class UsersMapper { public static class UsersMapper {
/// <summary>
/// Maps a User object to a UserInfoDto object.
/// </summary>
/// <param name="user">The User object to map.</param>
/// <returns>A UserInfoDto object containing the mapped data.</returns>
public static UserInfoDto ToGetUsersDto(this User user) { public static UserInfoDto ToGetUsersDto(this User user) {
return new UserInfoDto { return new UserInfoDto {
Id = user.Id, Id = user.Id,

View File

@@ -3,31 +3,61 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Lactose.Models; namespace Lactose.Models;
/// <summary>
/// Represents an album entity.
/// </summary>
public class Album { public class Album {
/// <summary>
/// Gets or sets the unique identifier for the album.
/// </summary>
[Key] [Key]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary>
/// Gets or sets the title of the album.
/// </summary>
[Column(TypeName = "VARCHAR(255)")] [Column(TypeName = "VARCHAR(255)")]
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the creation date of the album.
/// </summary>
[Required] [Required]
public DateTime? CreatedAt { get; set; } = DateTime.Now; public DateTime? CreatedAt { get; set; } = DateTime.Now;
/// <summary>
/// Gets or sets the last updated date of the album.
/// </summary>
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the user owner identifier.
/// </summary>
[ForeignKey(nameof(UserOwner))] [ForeignKey(nameof(UserOwner))]
public Guid? UserOwnerId { get; set; } public Guid? UserOwnerId { get; set; }
/// <summary>
/// Gets or sets the person owner identifier.
/// </summary>
[ForeignKey(nameof(PersonOwner))] [ForeignKey(nameof(PersonOwner))]
public Guid? PersonOwnerId { get; set; } public Guid? PersonOwnerId { get; set; }
#region Navigation Properties #region Navigation Properties
/// <summary>
/// Gets or sets the user owner of the album. This is the user account who created/owns the album.
/// </summary>
public User? UserOwner { get; set; } public User? UserOwner { get; set; }
/// <summary>
/// Gets or sets the person owner of the album. This is the person/model who appears in the album.
/// </summary>
public Person? PersonOwner { get; set; } public Person? PersonOwner { get; set; }
/// <summary>
/// Gets or sets the list of assets associated with the album.
/// </summary>
public List<Asset>? Assets { get; set; } public List<Asset>? Assets { get; set; }
#endregion #endregion
} }

View File

@@ -4,44 +4,98 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Lactose.Models; namespace Lactose.Models;
/// <summary>
/// Represents an asset in the system.
/// </summary>
public class Asset { public class Asset {
/// <summary>
/// Gets or sets the unique identifier for the asset.
/// </summary>
[Key] [Key]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary>
/// Gets or sets the original path of the asset.
/// </summary>
[Column(TypeName = "VARCHAR(2048)")] [Column(TypeName = "VARCHAR(2048)")]
public string OriginalPath { get; set; } = string.Empty; public string OriginalPath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the original filename of the asset.
/// </summary>
[Column(TypeName = "VARCHAR(255)")] [Column(TypeName = "VARCHAR(255)")]
public string OriginalFilename { get; set; } = string.Empty; public string OriginalFilename { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the thumbnail path of the asset.
/// </summary>
[Column(TypeName = "VARCHAR(2048)")] [Column(TypeName = "VARCHAR(2048)")]
public string ThumbnailPath { get; set; } = string.Empty; public string ThumbnailPath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the preview path of the asset.
/// </summary>
[Column(TypeName = "VARCHAR(2048)")] [Column(TypeName = "VARCHAR(2048)")]
public string PreviewPath { get; set; } = string.Empty; public string PreviewPath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the type of the asset.
/// </summary>
public EAssetType Type { get; set; } public EAssetType Type { get; set; }
/// <summary>
/// Gets or sets the owner ID of the asset.
/// </summary>
[ForeignKey(nameof(Owner))] [ForeignKey(nameof(Owner))]
public Guid? OwnerId { get; set; } public Guid? OwnerId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the asset is publicly shared.
/// </summary>
public bool IsPubliclyShared { get; set; } public bool IsPubliclyShared { get; set; }
/// <summary>
/// Gets or sets the creation date of the asset.
/// </summary>
[Required] [Required]
public DateTime CreatedAt { get; set; } = DateTime.Now; public DateTime CreatedAt { get; set; } = DateTime.Now;
/// <summary>
/// Gets or sets the last updated date of the asset.
/// </summary>
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the deletion date of the asset.
/// </summary>
public DateTime? DeletedAt { get; set; } public DateTime? DeletedAt { get; set; }
#region Navigation Properties #region Navigation Properties
public User? Owner { get; set; } /// <summary>
public List<User>? SharedWith { get; set; } /// Gets or sets the owner of the asset.
public List<Album>? Albums { get; set; } /// </summary>
public User? Owner { get; set; }
/// <summary>
/// Gets or sets the list of users with whom the asset is shared.
/// </summary>
public List<User>? SharedWith { get; set; }
/// <summary>
/// Gets or sets the list of albums associated with the asset.
/// </summary>
public List<Album>? Albums { get; set; }
/// <summary>
/// Gets or sets the list of tags associated with the asset.
/// </summary>
public List<Tag>? Tags { get; set; } public List<Tag>? Tags { get; set; }
/// <summary>
/// Gets or sets the list of faces detected in the asset.
/// </summary>
public List<Face>? Faces { get; set; } public List<Face>? Faces { get; set; }
#endregion #endregion
} }

View File

@@ -3,27 +3,69 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Lactose.Models; namespace Lactose.Models;
/// <summary>
/// Represents a detected face in an image.
/// </summary>
public class Face { public class Face {
/// <summary>
/// Gets or sets the unique identifier for the face.
/// </summary>
[Key] [Key]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary>
/// Gets or sets the X-coordinate of the top-left corner of the bounding box.
/// </summary>
public int BoundingBoxX1 { get; set; } public int BoundingBoxX1 { get; set; }
public int BoundingBoxY1 { get; set; }
public int BoundingBoxX2 { get; set; }
public int BoundingBoxY2 { get; set; }
public int ImageHeight { get; set; }
public int ImageWidth { get; set; }
/// <summary>
/// Gets or sets the Y-coordinate of the top-left corner of the bounding box.
/// </summary>
public int BoundingBoxY1 { get; set; }
/// <summary>
/// Gets or sets the X-coordinate of the bottom-right corner of the bounding box.
/// </summary>
public int BoundingBoxX2 { get; set; }
/// <summary>
/// Gets or sets the Y-coordinate of the bottom-right corner of the bounding box.
/// </summary>
public int BoundingBoxY2 { get; set; }
/// <summary>
/// Gets or sets the height of the image containing the face.
/// </summary>
public int ImageHeight { get; set; }
/// <summary>
/// Gets or sets the width of the image containing the face.
/// </summary>
public int ImageWidth { get; set; }
/// <summary>
/// Gets or sets the ID of the associated asset.
/// </summary>
[ForeignKey(nameof(Asset))] [ForeignKey(nameof(Asset))]
public Guid? AssetId { get; set; } public Guid? AssetId { get; set; }
/// <summary>
/// Gets or sets the ID of the associated person.
/// </summary>
[ForeignKey(nameof(Person))] [ForeignKey(nameof(Person))]
public Guid? PersonId { get; set; } public Guid? PersonId { get; set; }
#region Navigation Properties #region Navigation Properties
public Asset? Asset { get; set; } /// <summary>
/// Gets or sets the associated asset.
/// </summary>
public Asset? Asset { get; set; }
/// <summary>
/// Gets or sets the associated person.
/// </summary>
public Person? Person { get; set; } public Person? Person { get; set; }
#endregion #endregion
} }

View File

@@ -3,23 +3,49 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Lactose.Models; namespace Lactose.Models;
/// <summary>
/// Represents a person with associated metadata and navigation properties.
/// </summary>
public class Person { public class Person {
/// <summary>
/// Gets or sets the unique identifier for the person.
/// </summary>
[Key] [Key]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary>
/// Gets or sets the name of the person.
/// </summary>
[Column(TypeName = "VARCHAR(255)")] [Column(TypeName = "VARCHAR(255)")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the creation date and time of the person record.
/// </summary>
[Required] [Required]
public DateTime CreatedAt { get; set; } = DateTime.Now; public DateTime CreatedAt { get; set; } = DateTime.Now;
/// <summary>
/// Gets or sets the date and time when the person record was last updated.
/// </summary>
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the date and time when the person record was deleted.
/// </summary>
public DateTime? DeletedAt { get; set; } public DateTime? DeletedAt { get; set; }
#region Navigation Properties #region Navigation Properties
/// <summary>
/// Gets or sets the list of faces associated with the person.
/// </summary>
public List<Face>? Faces { get; set; } public List<Face>? Faces { get; set; }
/// <summary>
/// Gets or sets the list of albums associated with the person.
/// </summary>
public List<Album>? Albums { get; set; } public List<Album>? Albums { get; set; }
#endregion #endregion
} }

View File

@@ -2,22 +2,39 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace Lactose.Models; namespace Lactose.Models;
/// <summary>
/// Represents a tag entity with a unique identifier, name, and optional parent tag.
/// </summary>
public class Tag { public class Tag {
[Key] /// <summary>
public Guid Id { get; set; } /// Gets or sets the unique identifier for the tag.
/// </summary>
[Key]
public Guid Id { get; set; }
[Column(TypeName = "VARCHAR(255)")] /// <summary>
public string Name { get; set; } = string.Empty; /// Gets or sets the name of the tag.
/// </summary>
[Column(TypeName = "VARCHAR(255)")]
public string Name { get; set; } = string.Empty;
[ForeignKey(nameof(Parent))] /// <summary>
public Guid? ParentId { get; set; } /// Gets or sets the unique identifier of the parent tag, if any.
/// </summary>
[ForeignKey(nameof(Parent))]
public Guid? ParentId { get; set; }
#region Navigation Properties #region Navigation Properties
public Tag? Parent { get; set; } /// <summary>
/// Gets or sets the parent tag.
/// </summary>
public Tag? Parent { get; set; }
public List<Asset>? Assets { get; set; } /// <summary>
/// Gets or sets the list of assets associated with the tag.
/// </summary>
public List<Asset>? Assets { get; set; }
#endregion #endregion
} }

View File

@@ -5,34 +5,76 @@ using System.Text.Json.Serialization;
namespace Lactose.Models; namespace Lactose.Models;
/// <summary>
/// Represents a user in the system.
/// </summary>
public class User { public class User {
/// <summary>
/// Gets or sets the unique identifier for the user.
/// </summary>
[Key] [Key]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary>
/// Gets or sets the username of the user.
/// </summary>
[Column(TypeName = "VARCHAR(64)")] [Column(TypeName = "VARCHAR(64)")]
public string Username { get; set; } = string.Empty; public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the email address of the user.
/// </summary>
[Column(TypeName = "VARCHAR(128)")] [Column(TypeName = "VARCHAR(128)")]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the password of the user.
/// </summary>
[Column(TypeName = "VARCHAR(255)")][JsonIgnore] [Column(TypeName = "VARCHAR(255)")][JsonIgnore]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the date and time when the user was created.
/// </summary>
[Required] [Required]
public DateTime CreatedAt { get; set; } = DateTime.Now; public DateTime CreatedAt { get; set; } = DateTime.Now;
/// <summary>
/// Gets or sets the date and time when the user was last updated.
/// </summary>
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the date and time when the user last logged in.
/// </summary>
public DateTime? LastLogin { get; set; } public DateTime? LastLogin { get; set; }
/// <summary>
/// Gets or sets the date and time when the user was banned.
/// </summary>
public DateTime? BannedAt { get; set; } public DateTime? BannedAt { get; set; }
/// <summary>
/// Gets or sets the date and time when the user was deleted.
/// </summary>
//Todo: add to the mapper //Todo: add to the mapper
public DateTime? DeletedAt { get; set; } public DateTime? DeletedAt { get; set; }
/// <summary>
/// Gets or sets the access level of the user.
/// </summary>
public EAccessLevel AccessLevel { get; set; } public EAccessLevel AccessLevel { get; set; }
#region Navigation Properties #region Navigation Properties
/// <summary>
/// Gets or sets the list of assets owned by the user.
/// </summary>
public List<Asset>? OwnedAssets { get; set; } public List<Asset>? OwnedAssets { get; set; }
/// <summary>
/// Gets or sets the list of albums owned by the user.
/// </summary>
public List<Album>? OwnedAlbums { get; set; } public List<Album>? OwnedAlbums { get; set; }
#endregion #endregion