Example #1
0
    public async Task <Guid> CreateUserAsync(CreateUserCommand command)
    {
        var user = new User(
            command.UserName,
            command.Password,
            command.Name,
            command.DisplayName,
            command.IsEnabled);
        var roleIdsToAssign = command.RoleIds;
        var rolesToAssign   = await _roleRepository.GetRolesAsync(x => roleIdsToAssign.Contains(x.Id));

        foreach (var role in rolesToAssign)
        {
            user.AssignRole(role);
        }

        _userRepository.Add(user);
        await _unitOfWork.CommitAsync();

        return(user.Id);
    }
Example #2
0
 public async Task HandleAsync(EmployeeCreated @event)
 {
     Console.WriteLine("Handle" + DateTime.Now);
     await unitOfWork.CommitAsync();
 }