Ejemplo n.º 1
0
        public UserReturnModel SignUp(UserSignupModel signupModel, string userName)
        {
            if (!CheckCreditCardInformation(signupModel))
            {
                throw new UserInputException("Credit card information must be provided for any non-free account");
            }

            var existingUser = _userManager.GetUserByEmail(signupModel.EmailAddress);

            if (existingUser != null)
            {
                throw new UserInputException($"Account already exists for email address '{signupModel.EmailAddress}'");
            }

            var tier = _standardPricingTierManager.GetStandardPricingTier(signupModel.PricingTierId);

            if (tier == null)
            {
                throw new UserInputException($"Could not find AccountTypeId {signupModel.PricingTierId}");
            }

            var user = _userManager.AddNewuser(signupModel, tier, userName);

            _userManager.SetStandardSettings(user.UserId);

            return(MapUserToModel(user));
        }