There is an easy way to place all the coordinates with a \foreach loop. The figure can be drawn this way too, but you'll lose the visibility.
For example:
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d} % for 'canvas is...' options
\begin{document}
\tdplotsetmaincoords{70}{100}
\pgfmathsetmacro\n{7} % number of sides
\begin{tikzpicture}[tdplot_main_coords,line cap=butt,line join=round,%c/.style={circle,fill,inner sep=1pt},
declare function={r=3;r1=2;h=3;}]
\foreach\i in {1,...,\n}
{
\coordinate (A\i) at (360\i/\n:r);
\coordinate[canvas is xy plane at z=h] (B\i) at (360\i/\n:r1);
\draw (A\i) -- (B\i);
}
\foreach\i in {A,B}
\draw (\i1) foreach\j in {2,...,\n} {-- (\i\j)} -- cycle;
\end{tikzpicture}
\end{document}

Update 1 (a little help with the visibility): rotate the figure so that the vertex A1 be the first non-visible vertex on the right. Then set \vl as the number of the first visible vertex on the left. The rest is 'automatic'.
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d} % for 'canvas is...' options
\begin{document}
\tdplotsetmaincoords{70}{10} % <--- rotation
\pgfmathsetmacro\n{9} % number of sides
\pgfmathsetmacro\vl{5} % visibility limit
\pgfmathtruncatemacro\vv{\vl+1}
\begin{tikzpicture}[tdplot_main_coords,line cap=butt,line join=round,
declare function={r=3;r1=2;h=3;}]
\foreach\i in {1,...,\n}
{
\coordinate (A\i) at (360\i/\n:r);
\coordinate[canvas is xy plane at z=h] (B\i) at (360\i/\n:r1);
\pgfmathtruncatemacro\ii{\i+1}
\draw[\ifnum\i<\vl dashed\fi] (A\i) -- (B\i);
}
\draw (B1) foreach\j in {2,...,\n} {-- (B\j)} -- cycle;
\foreach\j in {1,...,\n}
\pgfmathtruncatemacro\i{mod(\j,\n)+1}
\draw[\ifnum\i<\vv dashed\fi] (A\i) -- (A\j);
% only for help:
\foreach\i in {1,...,\n}
\node[red,below] at (A\i) {$\i$};
\end{tikzpicture}
\end{document}

Update 2: Just changing
\pgfmathsetmacro\n{3} % number of sides
\pgfmathsetmacro\vl{2} % visibility limit
the output will be

\usetikzlibrary{3d}I get the same result your. Can you draw dashed lines automatically? – John Paul Peter Apr 30 '23 at 07:29B_{i-1}? – John Paul Peter May 03 '23 at 08:47\node at (0,0) {\pgfmathparse{int(\i-1)}$B_{\pgfmathresult}$};– Juan Castaño May 03 '23 at 09:03A_{i-1} -- B_{i-1}. What is the syntax? – John Paul Peter May 03 '23 at 09:09i-1, store it and then draw:\pgfmathtruncatemacro\j{\i-1} \draw (A\j) -- (B\j);. – Juan Castaño May 03 '23 at 09:16