InitEshop+ddd+ca

This commit is contained in:
Matěj Kubíček
2026-07-16 18:33:05 +02:00
parent ffd8a087c8
commit 7e080eaef9
144 changed files with 972 additions and 1339 deletions
@@ -0,0 +1,9 @@
namespace Eshop.Application.Auth;
public sealed class SignInResultDto
{
public bool Succeeded { get; private init; }
public static SignInResultDto Success => new() { Succeeded = true };
public static SignInResultDto Failure => new() { Succeeded = false };
}
@@ -0,0 +1,8 @@
namespace Eshop.Application.Auth;
public sealed record UserDataExportDto(
string Id,
string UserName,
string Email,
IReadOnlyList<string> Roles,
DateTime ExportDate);
@@ -0,0 +1,3 @@
namespace Eshop.Application.Auth;
public sealed record UserDto(string Id, string UserName, string Email);
@@ -0,0 +1,3 @@
namespace Eshop.Application.Auth;
public sealed record UserProfileDto(string UserName, string Email);
@@ -0,0 +1,6 @@
namespace Eshop.Application.Auth;
public sealed record UserWithRolesDto(
UserDto User,
IReadOnlyList<string> Roles,
IReadOnlyList<string> AllRoles);
@@ -0,0 +1,12 @@
namespace Eshop.Application.Auth;
public interface IAuthenticationService
{
Task<SignInResultDto> SignInAsync(
string emailOrUsername,
string password,
bool rememberMe,
CancellationToken cancellationToken = default);
Task SignOutAsync(CancellationToken cancellationToken = default);
}
@@ -0,0 +1,29 @@
using Eshop.Application.Common;
namespace Eshop.Application.Auth;
public interface IUserAccountService
{
Task<ServiceResult> RegisterAsync(
string userName,
string email,
string password,
CancellationToken cancellationToken = default);
Task<UserProfileDto?> GetProfileAsync(
string userId,
CancellationToken cancellationToken = default);
Task<ServiceResult> UpdateProfileAsync(
string userId,
UpdateProfileRequest request,
CancellationToken cancellationToken = default);
Task<ServiceResult> DeleteAccountAsync(
string userId,
CancellationToken cancellationToken = default);
Task<UserDataExportDto?> ExportUserDataAsync(
string userId,
CancellationToken cancellationToken = default);
}
@@ -0,0 +1,18 @@
using Eshop.Application.Common;
namespace Eshop.Application.Auth;
public interface IUserAdministrationService
{
Task<IReadOnlyList<UserWithRolesDto>> GetAllUsersWithRolesAsync(
CancellationToken cancellationToken = default);
Task<UserWithRolesDto?> GetUserWithRolesAsync(
string userId,
CancellationToken cancellationToken = default);
Task<ServiceResult> UpdateUserRolesAsync(
string userId,
IReadOnlyList<string> selectedRoles,
CancellationToken cancellationToken = default);
}
@@ -0,0 +1,7 @@
namespace Eshop.Application.Auth;
public sealed record UpdateProfileRequest(
string UserName,
string Email,
string? CurrentPassword,
string? NewPassword);
@@ -0,0 +1,28 @@
namespace Eshop.Application.Common;
public class ServiceResult
{
public bool Success { get; protected set; }
public IReadOnlyList<string> Errors { get; protected set; } = [];
public static ServiceResult Ok() => new() { Success = true };
public static ServiceResult Failure(string message) =>
new() { Success = false, Errors = [message] };
public static ServiceResult Failure(IEnumerable<string> errors) =>
new() { Success = false, Errors = errors.ToList() };
}
public class ServiceResult<T> : ServiceResult
{
public T? Data { get; private set; }
public static ServiceResult<T> Ok(T data) => new() { Success = true, Data = data };
public new static ServiceResult<T> Failure(string message) =>
new() { Success = false, Errors = [message] };
public new static ServiceResult<T> Failure(IEnumerable<string> errors) =>
new() { Success = false, Errors = errors.ToList() };
}
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Eshop.Domain\Eshop.Domain.csproj" />
</ItemGroup>
</Project>