Exemplo n.º 1
0
        /// <summary>
        /// Creates the user.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="password">The password.</param>
        /// <param name="passwordQuestion">The password question.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <param name="remoteIp">The remote ip.</param>
        /// <returns></returns>
        public SecurityUser CreateSecurityUser(string email, string password, int passwordQuestion, string passwordAnswer, string remoteIp)
        {
            SecurityUser user;

            using (var sqlConnection = GetOpenedSqlConnection2())
            {
                var createCustomerCommand = new CreateUser()
                                            .SetEmailAndPassword(email, password)
                                            .SetSecurityQuestionId(passwordQuestion)
                                            .SetSecurityQuestionAnswer(passwordAnswer)
                                            .SetRoleName(roleName) //TODO: find some other way to obtain role
                                            .SetRemoteIp(remoteIp);

                using (SqlCommand sqlCommand = createCustomerCommand.Get(sqlConnection.SqlConnection())) {
                    user = CreateModel <SecurityUser>(sqlCommand.ExecuteReader());
                }
            }

            return(user);
        }