Example #1
0
        public static ActionResult <UserModel> Execute(PostNewUserType data, string connectionString)
        {
            try
            {
                using (var connection = new SqlConnection(connectionString))
                {
                    // create command object
                    var command = new SqlCommand();
                    command.Connection = connection;
                    command.Connection.Open();

                    // insert new user into users table
                    command.CommandText = @$ "
                        INSERT INTO users ( name
                                          , user_role
                                          , username
                                          , email
                                          )
                             OUTPUT inserted.*
                             VALUES ( '{data.name}'
                                    , '{data.userRole}'
Example #2
0
 public ActionResult <UserModel> PostNewUser([FromBody] PostNewUserType data)
 {
     return(postNewUser.Execute(data, _configuration["ConnectionStrings:DefaultConnection"]));
 }