Adds skeleton Users management system

This commit is contained in:
BinaryAlley committed 2024-11-03 15:26:38 +02:00
1 parent faa9ce7729
commit 3dd6a0a6ca
15 files changed
+804 -40

No files matched your search

@@ -14,7 +14,7 @@ using System.Diagnostics;
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
/// <summary>
/// Aggregate root for a book.
/// Aggregate root for a book library aggregate.
/// </summary>
[DebuggerDisplay("{Id}: {Title}")]
public sealed class Book : AggregateRoot<BookId>
@@ -322,4 +322,4 @@ public sealed class Book : AggregateRoot<BookId>
contributors,
ratings);
}
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Aggregate root for a user aggregate.
/// </summary>
[DebuggerDisplay("{Id}: {Username}")]
public sealed class User : AggregateRoot<UserId>
{
/// <summary>
/// Gets or sets the username of the user.
/// </summary>
public string Username { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// </summary>
/// <param name="id">The unique identifier of the user.</param>
/// <param name="username">The username of the user.</param>
private User(
UserId id,
string username) : base(id)
{
Username = username;
}
/// <summary>
/// Creates a new instance of the <see cref="User"/> class.
/// </summary>
/// <param name="username">The username of the user.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message.
/// </returns>
public static ErrorOr<User> Create(
string username)
{
return new User(
UserId.CreateUnique(),
username);
}
/// <summary>
/// Creates a new instance of the <see cref="User"/>, with a pre-existing <paramref name="id"/>.
/// </summary>
/// <param name="id">The object representing the id of the user.</param>
/// <param name="username">The username of the user.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message.
/// </returns>
public static ErrorOr<User> Create(
UserId id,
string username)
{
return new User(
id,
username);
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a user.
/// </summary>
[DebuggerDisplay("{Value}")]
public sealed class UserId : EntityId<Guid>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserId"/> class.
/// </summary>
/// <param name="value">The value representing this object.</param>
private UserId(Guid value) : base(value)
{
}
/// <summary>
/// Creates a new instance of the <see cref="UserId"/> class.
/// </summary>
/// <returns>The created <see cref="UserId"/> instance.</returns>
public static UserId CreateUnique()
{
return new UserId(Guid.NewGuid());
}
/// <summary>
/// Creates a new instance of the <see cref="UserId"/> class, from a pre-existing <paramref name="value"/>.
/// </summary>
/// <param name="value">The value used to create the <see cref="UserId"/> instance.</param>
/// <returns>The created <see cref="UserId"/> instance.</returns>
public static UserId Create(Guid value)
{
return new UserId(value);
}
/// <inheritdoc/>
public override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
}