XML Documentation Pass
This commit is contained in:
@@ -4,7 +4,16 @@ using Lactose.Types;
|
||||
|
||||
namespace Lactose.Mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Provides mapping methods for converting Asset objects to DTOs.
|
||||
/// </summary>
|
||||
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 {
|
||||
Id = asset.Id,
|
||||
FileName = accessLevel >= EAccessLevel.Curator ? asset.OriginalFilename : null,
|
||||
@@ -16,10 +25,20 @@ public static class AssetsMapper {
|
||||
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 {
|
||||
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)
|
||||
=> assets.Select(ToAssetPreviewDto);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,15 @@ using Lactose.Models;
|
||||
|
||||
namespace Lactose.Mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Provides methods for mapping Tag objects to TagDto objects.
|
||||
/// </summary>
|
||||
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) {
|
||||
return new TagDto() {
|
||||
Id = tag.Id,
|
||||
@@ -13,4 +21,4 @@ public static class TagsMapper {
|
||||
Parent = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,15 @@ using Lactose.Models;
|
||||
|
||||
namespace Lactose.Mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Provides mapping methods for User objects.
|
||||
/// </summary>
|
||||
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) {
|
||||
return new UserInfoDto {
|
||||
Id = user.Id,
|
||||
|
||||
@@ -3,31 +3,61 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Lactose.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an album entity.
|
||||
/// </summary>
|
||||
public class Album {
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for the album.
|
||||
/// </summary>
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the album.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(255)")]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the creation date of the album.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime? CreatedAt { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last updated date of the album.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user owner identifier.
|
||||
/// </summary>
|
||||
[ForeignKey(nameof(UserOwner))]
|
||||
public Guid? UserOwnerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the person owner identifier.
|
||||
/// </summary>
|
||||
[ForeignKey(nameof(PersonOwner))]
|
||||
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; }
|
||||
|
||||
/// <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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of assets associated with the album.
|
||||
/// </summary>
|
||||
public List<Asset>? Assets { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -4,44 +4,98 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Lactose.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an asset in the system.
|
||||
/// </summary>
|
||||
public class Asset {
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for the asset.
|
||||
/// </summary>
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original path of the asset.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(2048)")]
|
||||
public string OriginalPath { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original filename of the asset.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(255)")]
|
||||
public string OriginalFilename { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thumbnail path of the asset.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(2048)")]
|
||||
public string ThumbnailPath { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the preview path of the asset.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(2048)")]
|
||||
public string PreviewPath { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the asset.
|
||||
/// </summary>
|
||||
public EAssetType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the owner ID of the asset.
|
||||
/// </summary>
|
||||
[ForeignKey(nameof(Owner))]
|
||||
public Guid? OwnerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the asset is publicly shared.
|
||||
/// </summary>
|
||||
public bool IsPubliclyShared { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the creation date of the asset.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last updated date of the asset.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the deletion date of the asset.
|
||||
/// </summary>
|
||||
public DateTime? DeletedAt { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
#region Navigation Properties
|
||||
|
||||
public User? Owner { get; set; }
|
||||
public List<User>? SharedWith { get; set; }
|
||||
public List<Album>? Albums { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the owner of the asset.
|
||||
/// </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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of faces detected in the asset.
|
||||
/// </summary>
|
||||
public List<Face>? Faces { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -3,27 +3,69 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Lactose.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a detected face in an image.
|
||||
/// </summary>
|
||||
public class Face {
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for the face.
|
||||
/// </summary>
|
||||
[Key]
|
||||
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 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))]
|
||||
public Guid? AssetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ID of the associated person.
|
||||
/// </summary>
|
||||
[ForeignKey(nameof(Person))]
|
||||
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; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -3,23 +3,49 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Lactose.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a person with associated metadata and navigation properties.
|
||||
/// </summary>
|
||||
public class Person {
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for the person.
|
||||
/// </summary>
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the person.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(255)")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the creation date and time of the person record.
|
||||
/// </summary>
|
||||
[Required]
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the person record was deleted.
|
||||
/// </summary>
|
||||
public DateTime? DeletedAt { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of faces associated with the person.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,39 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Lactose.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a tag entity with a unique identifier, name, and optional parent tag.
|
||||
/// </summary>
|
||||
public class Tag {
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for the tag.
|
||||
/// </summary>
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Column(TypeName = "VARCHAR(255)")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the tag.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(255)")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[ForeignKey(nameof(Parent))]
|
||||
public Guid? ParentId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the parent tag, if any.
|
||||
/// </summary>
|
||||
[ForeignKey(nameof(Parent))]
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
@@ -5,34 +5,76 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace Lactose.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a user in the system.
|
||||
/// </summary>
|
||||
public class User {
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for the user.
|
||||
/// </summary>
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username of the user.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(64)")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the email address of the user.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(128)")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password of the user.
|
||||
/// </summary>
|
||||
[Column(TypeName = "VARCHAR(255)")][JsonIgnore]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the user was created.
|
||||
/// </summary>
|
||||
[Required]
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the user last logged in.
|
||||
/// </summary>
|
||||
public DateTime? LastLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the user was banned.
|
||||
/// </summary>
|
||||
public DateTime? BannedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the user was deleted.
|
||||
/// </summary>
|
||||
//Todo: add to the mapper
|
||||
public DateTime? DeletedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the access level of the user.
|
||||
/// </summary>
|
||||
public EAccessLevel AccessLevel { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of assets owned by the user.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user