Esempio n. 1
0
        public User Create(User request)
        {
            var response = request;

            using (SqlConnection conn = new SqlConnection(ConnectionString())) {
                using (var cmd = new SqlCommand()) {
                    cmd.Connection  = conn;
                    cmd.CommandText = _userSql.SqlCreate();
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@Name", GetDbValue(request.Name));
                    cmd.Parameters.AddWithValue("@Email", GetDbValue(request.Email));
                    cmd.Parameters.AddWithValue("@Password", GetDbValue(request.Password));

                    conn.Open();
                    response.Id = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }

            return(response);
        }