Esempio n. 1
0
        /// <inheritdoc/>
        public async Task <UserDto> Handle(RegisterUserCommand request, CancellationToken cancellationToken)
        {
            var user   = mapper.Map <Domain.Entities.User>(request);
            var result = await userManager.CreateAsync(user, request.Password);

            if (!result.Succeeded)
            {
                throw new ValidationException(ValidationErrors.CreateFromErrors(
                                                  "An error occurred in user registration!",
                                                  result.Errors.Select(e => e.Description).ToArray()));
            }

            return(mapper.Map <UserDto>(user));
        }