Beispiel #1
0
        public async Task <IActionResult> Register([FromBody] RegisterBindingModel model)
        {
            // Check if user already exists
            var userExists = await _userRepository.ExistsAsync(x => x.Email == model.Email);

            if (userExists)
            {
                return(BadRequest(new BadRequestResponseModel(ErrorMessages.AuthenticatinError, "User already exists")));
            }

            var user = _mapper.Map <ApplicationCore.Entities.Participant>(model);

            user.Password = _passwordHasher.Hash(model.Password);
            user.Username = model.Email;

            // Later this fields will be enabled disabled by apis as required.
            user.Verified = false;
            user.Active   = false;

            await _userRepository.AddAsync(user);

            _logger.Info($"{user.Username} account created.");

            // Create zoom account
            var zoomUserInfo = _mapper.Map <ZoomUserInfo>(user);
            var response     = await _zoomApiService.CreateUserAsync(zoomUserInfo);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                _logger.Error(response.ErrorMessage);
            }

            var zoomUser = JsonConvert.DeserializeObject <ZoomUserInfo>(response.Content);

            user.ZoomUserId = zoomUser.Id;
            await _userRepository.UpdateAsync(user);

            return(Ok());
        }
Beispiel #2
0
        public async Task <IActionResult> CreateZoomUser(int userId)
        {
            var participant = await _participantRepsitory.FindAsync(userId);

            var zoomUserInfo = _mapper.Map <ZoomUserInfo>(participant);
            var response     = await _zoomApiService.CreateUserAsync(zoomUserInfo);

            if (response.StatusCode != HttpStatusCode.Created)
            {
                return(BadRequest(new BadRequestResponseModel(ErrorTypes.BadRequest, response.ErrorMessage)));
            }

            var zoomUser = JsonConvert.DeserializeObject <ZoomUserInfo>(response.Content);

            participant.ZoomUserId = zoomUser.Id;
            await _participantRepsitory.UpdateAsync(participant);

            return(Ok());
        }
Beispiel #3
0
        public async Task <IActionResult> CreateZoomUser()
        {
            var user = await _userRepository.FindAsync(UserId);

            var zoomUserInfo = _mapper.Map <ZoomUserInfo>(user);
            var response     = await _zoomApiService.CreateUserAsync(zoomUserInfo);

            if (response.StatusCode != System.Net.HttpStatusCode.Created)
            {
                return(BadRequest(response.ErrorMessage));
            }

            var zoomUser = JsonConvert.DeserializeObject <ZoomUserInfo>(response.Content);

            user.ZoomUserId = zoomUser.Id;
            await _userRepository.UpdateAsync(user);

            return(Ok());
        }