Esempio n. 1
0
        /// <summary>
        ///   Validate validation code of user.
        /// </summary>
        /// <param name="validateModel">Model of validation user.</param>
        /// <returns>
        ///    Validated user registration profile.
        /// </returns>
        /// <exception cref="System.ArgumentException">When one of params invalid.</exception>
        /// <exception cref="System.UnauthorizedAccessException">When user id of description != current user id.</exception>

        public async Task <User> ValidateEmail(ValidateModel validateModel, long currentUserId)
        {
            validateModel.CheckArgumentException();

            var user = await _userRepository.GetAsync(validateModel.UserId);

            user.EmailIsValidated = user.Id == currentUserId?
                                    validateModel.ValidationCode.ValidateCode(user.Email)
                                        : throw new UnauthorizedAccessException();

            return((await _userRepository.EditAsync(user))
                   .GetSkillsToUser(_userSkillRepository, _skillRepository));
        }
Esempio n. 2
0
        /// <summary>
        ///   Validate validation code of user.
        /// </summary>
        /// <param name="validateModel">Model of validation user.</param>
        /// <returns>
        ///    Validated user registration profile.
        /// </returns>
        /// <exception cref="System.ArgumentException">When one of params invalid.</exception>
        /// <exception cref="System.ArgumentNullException">When user not found.</exception>

        public async Task <User> ValidateRegistration(ValidateModel validateModel)
        {
            validateModel.CheckArgumentException();

            var user = await _userRepository
                       .GetAsync(validateModel.UserId);

            user.TelephoneNumberIsValidated =
                validateModel
                .ValidationCode
                .ValidateCode(user.TelephoneNumber);

            return(await _userRepository.EditAsync(user));
        }