Question:
Why am I not getting the correct $b_n$ for the Fourier series for the given function below? Why does my answer have an $x$ in it?

Textbook Answer
As shown above $b_n = \frac{(-1)^{n+1}}{n}$
My Work (via integration of parts) $$ b_n = \frac{1}{L} \int_{-L}^{L} f(x)sin(\frac{n\pi x}{L}) dx $$ $$ b_n = \frac{1}{\pi} \int_{-\pi}^{0} xsin(nx) dx = \frac{-x}{n}cos(nx) + \int_{-\pi}^{0} \frac{cos(nx)}{n} dx = \frac{-x}{n}cos(nx) + 0 $$ This means that $$ \frac{-x}{n}cos(nx)= \begin{cases} \frac{-x}{n},& \text{if n is even }\\ \frac{x}{n}, & \text{if n is odd} \end{cases} $$ so $b_n = \frac{x}{n}(-1)^{n+1}$ for $n=1,2,3,..$
You did not use the integral limits $$b_n = \frac{1}{\pi} \int_{-\pi}^{0} xsin(nx) dx \\=\frac{1}{\pi}\left( \frac{-x}{n}cos(nx) \right)|_{-\pi}^0+\frac{1}{\pi} \int_{-\pi}^{0} \frac{cos(nx)}{n} dx \\= \frac{-1}{n}cos(n\pi) + 0 \\=\frac{-1}{n}(-1)^{n+1}$$
Therefore, $b_n = \frac{-1}{n}(-1)^{n+1}$