105 lines
2.1 KiB
C#
105 lines
2.1 KiB
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using MediatR;
|
|
|
|
namespace EnvelopeGenerator.Application.Users.Commands;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public record CreateUserCommand : IRequest<int>
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Prename { get; init; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Name { get; init; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public required string Username { get; init; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Shortname { get; init; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Email { get; init; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string Language { get; init; } = "de-DE";
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string? Comment { get; init; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool Deleted { get; } = false;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string DateFormat { get; init; } = "dd.MM.yyyy";
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool Active { get; } = true;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string GeneralViewer { get; init; } = "NONE";
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool WanEnvironment { get; } = false;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public int UserIdFkIntEcm { get; init; } = 0;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class CreateUserCommandHandler : IRequestHandler<CreateUserCommand, int>
|
|
{
|
|
private readonly IRepository<User> _repo;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="repo"></param>
|
|
public CreateUserCommandHandler(IRepository<User> repo)
|
|
{
|
|
_repo = repo;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="cancel"></param>
|
|
/// <returns></returns>
|
|
public async Task<int> Handle(CreateUserCommand request, CancellationToken cancel = default)
|
|
{
|
|
var user = await _repo.CreateAsync(request, cancel);
|
|
return user.Id;
|
|
}
|
|
} |