using Domain.Entities;
using Domain.Exceptions;
using Infrastructure.Repository.UserAccount;
namespace Service.UserManagement.User;
///
/// Handles retrieval and update of user accounts.
///
/// Repository used to persist and query user account data.
public class UserService(IUserAccountRepository repository) : IUserService
{
///
/// Retrieves all user accounts, optionally paginated.
///
/// The maximum number of results to return, or null for no limit.
/// The number of results to skip, or null to start from the beginning.
/// A collection of entities.
public async Task> GetAllAsync(
int? limit = null,
int? offset = null
)
{
return await repository.GetAllAsync(limit, offset);
}
///
/// Retrieves a user account by its unique identifier.
///
/// The unique identifier of the user account.
/// The matching .
/// Thrown when no user account exists with the given .
public async Task GetByIdAsync(Guid id)
{
var user = await repository.GetByIdAsync(id);
if (user is null)
throw new NotFoundException($"User with ID {id} not found");
return user;
}
///
/// Updates an existing user account.
///
/// The user account containing the updated data.
/// A task that completes once the update has finished.
public async Task UpdateAsync(UserAccount userAccount)
{
await repository.UpdateAsync(userAccount);
}
}